dotnet/wpf · error · ArgumentException
Microsoft.Windows.Controls.SR.Format(Microsoft.Windows.Contr…
Error message
Microsoft.Windows.Controls.SR.Format(Microsoft.Windows.Controls.SR.InvalidCtorParameterUnknownRibbonControlLengthUnitType, "type")
What it means
The RibbonControlLength(value, type) constructor throws this ArgumentException when type is not a recognized RibbonControlLengthUnitType value (Auto, Pixel, Star or the sentinel). An undefined enum value passed to the constructor is rejected immediately, signaling a programming error.
Solutions
- Use one of the defined RibbonControlLengthUnitType values (Auto, Pixel, Star)
- Ensure the type argument is not an uninitialized or cast-invalid enum value
- Default to RibbonControlLengthUnitType.Pixel when the type is unknown
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonControlLength.cs:63 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/a1418540f7b35773.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonControlLength.cs:63
/// </summary>
public RibbonControlLength(double value, RibbonControlLengthUnitType type)
{
if (double.IsNaN(value))
{
throw new ArgumentException(Microsoft.Windows.Controls.SR.Format(Microsoft.Windows.Controls.SR.InvalidCtorParameterNoNaN, "value"));
}
if (type == RibbonControlLengthUnitType.Star && double.IsInfinity(value))
{
throw new ArgumentException(Microsoft.Windows.Controls.SR.Format(Microsoft.Windows.Controls.SR.InvalidCtorParameterNoInfinityForStarSize, "value"));
}
if (type != RibbonControlLengthUnitType.Auto
&& type != RibbonControlLengthUnitType.Pixel
&& type != RibbonControlLengthUnitType.Item
&& type != RibbonControlLengthUnitType.Star)
{
throw new ArgumentException(Microsoft.Windows.Controls.SR.Format(Microsoft.Windows.Controls.SR.InvalidCtorParameterUnknownRibbonControlLengthUnitType, "type"));
}
_unitValue = (type == RibbonControlLengthUnitType.Auto) ? 0.0 : value;
_unitType = type;
}
#endregion
#region Public Methods
/// <summary>
/// Overloaded operator, compares 2 RibbonControlLengths.
/// </summary>
public static bool operator ==(RibbonControlLength length1, RibbonControlLength length2)
{
return (length1.RibbonControlLengthUnitType == length2.RibbonControlLengthUnitType &&
length1.Value == length2.Value);
}View on GitHub (pinned to 81131a70a4)