dotnet/wpf · error · ArgumentException
SR.Format(SR.InvalidCtorParameterNoInfinity, "value")
Error message
SR.Format(SR.InvalidCtorParameterNoInfinity, "value")
What it means
The FigureLength constructor rejects a value of double.PositiveInfinity or double.NegativeInfinity. Infinity is not a valid figure length; the constructor throws ArgumentException with InvalidCtorParameterNoInfinity.
Solutions
- Clamp or validate with double.IsInfinity before constructing the FigureLength.
- Use FigureUnitType.Page or Content to express 'fill' semantics instead of infinity.
- Fix upstream math that yields infinity (e.g. division by zero or max on empty collections).
Example fix
// before
var length = new FigureLength(double.PositiveInfinity, FigureUnitType.Pixel); // throws
// after
var length = double.IsInfinity(requested)
? new FigureLength(1.0, FigureUnitType.Page)
: new FigureLength(requested, FigureUnitType.Pixel); Defensive patterns
Strategy: validation
Validate before calling
if (double.IsInfinity(value))
throw new ArgumentException("value must not be infinite.");
var length = new FigureLength(value, unit); Type guard
bool IsFiniteLength(double v) => !double.IsNaN(v) && !double.IsInfinity(v);
Try / catch
try { var len = new FigureLength(value, unit); }
catch (ArgumentException) { /* clamp or fall back to Page/Content unit */ } Prevention
- Never use double.PositiveInfinity as a 'fill' convention; use FigureUnitType.Page or Content.
- Guard division and Max operations that can yield infinity.
- Clamp values to PTS restrictions (max pixel/page sizes) before constructing.
When it happens
Trigger: Calling new FigureLength(double.PositiveInfinity, ...) or with NegativeInfinity — e.g. passing double.PositiveInfinity to mean 'fill available space'.
Common situations: Using double.PositiveInfinity as a 'stretch to max' convention in layout code; values computed from unbounded measurements; interop with code that uses infinity as a default.
Related errors
- SR.Format(SR.InvalidCtorParameterNoInfinity, "value")
- SR.Format(SR.InvalidCtorParameterNoNaN, "value")
- ArgumentNullException
- ArgumentNullException(nameof(assemblyNames))
- ArgumentNullException(nameof(contentType))
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/cfea135c0c6d066b.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FigureLength.cs:107
/// </remarks>
/// <exception cref="ArgumentException">
/// If <c>value</c> parameter is <c>double.NaN</c>
/// or <c>value</c> parameter is <c>double.NegativeInfinity</c>
/// or <c>value</c> parameter is <c>double.PositiveInfinity</c>.
/// or <c>value</c> parameter is <c>negative</c>.
/// </exception>
public FigureLength(double value, FigureUnitType type)
{
double maxColumns = PTS.Restrictions.tscColumnRestriction;
double maxPixel = Math.Min(1000000, PTS.MaxPageSize);
if (double.IsNaN(value))
{
throw new ArgumentException(SR.Format(SR.InvalidCtorParameterNoNaN, "value"));
}
if (double.IsInfinity(value))
{
throw new ArgumentException(SR.Format(SR.InvalidCtorParameterNoInfinity, "value"));
}
if (value < 0.0)
{
throw new ArgumentOutOfRangeException(SR.Format(SR.InvalidCtorParameterNoNegative, "value"));
}
if ( type != FigureUnitType.Auto
&& type != FigureUnitType.Pixel
&& type != FigureUnitType.Column
&& type != FigureUnitType.Content
&& type != FigureUnitType.Page )
{
throw new ArgumentException(SR.Format(SR.InvalidCtorParameterUnknownFigureUnitType, "type"));
}
if (type is FigureUnitType.Content or FigureUnitType.Page)
{
ArgumentOutOfRangeException.ThrowIfGreaterThan(value, 1.0);
}
View on GitHub (pinned to 81131a70a4)