dotnet/wpf · error · ArgumentException
SR.InvalidStylusPointPropertyInfoResolution
Error message
SR.InvalidStylusPointPropertyInfoResolution
What it means
StylusPointPropertyInfo's constructor validates that the resolution is non-negative. A negative resolution (samples per unit) is meaningless, so ArgumentException SR.InvalidStylusPointPropertyInfoResolution is thrown for the 'resolution' parameter.
Solutions
- Pass a positive resolution value; treat unknown as a sensible default rather than a negative number
- Clamp with Math.Max(0f, resolution) before constructing
- Fix the upstream parsing of device metrics so sentinel values don't leak in
Example fix
// before new StylusPointPropertyInfo(prop, unit, -400f, 0, 100); // after new StylusPointPropertyInfo(prop, unit, Math.Max(0f, resolution), 0, 100);
Defensive patterns
Strategy: validation
Validate before calling
if (resolution < 0f) resolution = 0f; // or reject var info = new StylusPointPropertyInfo(prop, unit, resolution, min, max);
Try / catch
try { var info = new StylusPointPropertyInfo(prop, unit, res, min, max); }
catch (ArgumentException ex) when (ex.ParamName == "resolution") { /* substitute default resolution */ } Prevention
- Treat negative/unknown resolution as 'use default', never pass it through
- Validate parsed device metrics before constructing property infos
When it happens
Trigger: Calling new StylusPointPropertyInfo(...) with a negative float for resolution, typically from misparsed or defaulted device metrics.
Common situations: Parsing device description XML where a resolution field is negative or a sentinel (-1) meaning 'unknown'; arithmetic producing negative results for high-resolution axes.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- captureMode
- SR.InvalidStylusPointConstructionZeroLengthCollection
- SR.Stylus_InvalidMax
- SR.Stylus_MatrixNotInvertable
- ' ' is not a valid value for ' '.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/16f33c032e608c3e.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointPropertyInfo.cs:62
public StylusPointPropertyInfo(StylusPointProperty stylusPointProperty, int minimum, int maximum, StylusPointPropertyUnit unit, float resolution)
: base(stylusPointProperty) //base checks for null
{
// validate unit
if (!StylusPointPropertyUnitHelper.IsDefined(unit))
{
throw new InvalidEnumArgumentException("unit", (int)unit, typeof(StylusPointPropertyUnit));
}
// validate min/max
if (maximum < minimum)
{
throw new ArgumentException(SR.Stylus_InvalidMax, nameof(maximum));
}
// validate resolution
if (resolution < 0.0f)
{
throw new ArgumentException(SR.InvalidStylusPointPropertyInfoResolution, nameof(resolution));
}
_min = minimum;
_max = maximum;
_resolution = resolution;
_unit = unit;
}
/// <summary>
/// Minimum
/// </summary>
public int Minimum
{
get { return _min; }
}
/// <summary>
/// MaximumView on GitHub (pinned to 81131a70a4)