dotnet/wpf · error · ArgumentException
Microsoft.Windows.Controls.SR.Format(Microsoft.Windows.Contr…
Error message
Microsoft.Windows.Controls.SR.Format(Microsoft.Windows.Controls.SR.InvalidCtorParameterNoInfinityForStarSize, "value")
What it means
The RibbonControlLength(value, type) constructor throws this ArgumentException when type is Star and value is PositiveInfinity or NegativeInfinity. Star sizing weights must be finite; infinity is not a valid star value, so the constructor rejects it at construction time.
Solutions
- Pass a finite double (not double.PositiveInfinity/NegativeInfinity) when constructing a RibbonControlLength with Star sizing
- Use RibbonControlLength.Auto or a Pixel value if a special size is needed
- Validate/clamp the value before constructing
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:55 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/4a418538f3d55c65.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonControlLength.cs:55
public RibbonControlLength(double pixels)
: this(pixels, RibbonControlLengthUnitType.Pixel)
{
}
/// <summary>
/// Constructor, initializes the RibbonControlLength and specifies what kind of value
/// it will hold.
/// </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
View on GitHub (pinned to 81131a70a4)