dotnet/wpf · error · ArgumentOutOfRangeException
SR.RangeValueMin
Error message
SR.RangeValueMin
What it means
SetValue on the Windows Up/Down RangeValue provider throws ArgumentOutOfRangeException with SR.RangeValueMin when the requested value is below the control's Minimum. Positions below Min cannot be represented by the native updown control, so the value is rejected before UDM_SETPOS is sent.
Solutions
- Clamp the value to the pattern's Minimum before calling SetValue
- Re-read RangeValuePattern.Minimum at call time instead of caching
- Adjust the application's updown range (UDM_SETRANGE32) if the minimum is wrong
- Catch ArgumentOutOfRangeException and include Min/Max in the failure message
Example fix
// before rangeValuePattern.SetValue(value); // after var rv = rangeValuePattern.Current; rangeValuePattern.SetValue(Math.Min(Math.Max(value, rv.Minimum), rv.Maximum));
Defensive patterns
Strategy: validation
Validate before calling
var rv = rangeValuePattern.Current; value = Math.Clamp(value, rv.Minimum, rv.Maximum);
Type guard
bool InRange(double v, double min, double max) => v >= min && v <= max;
Try / catch
try { rangeValuePattern.SetValue(value); }
catch (ArgumentOutOfRangeException ex) { log($"{value} below spinner Minimum {rv.Minimum}"); } Prevention
- Clamp to the pattern's live Minimum/Maximum before SetValue
- Re-read Minimum at call time instead of hard-coding 0
- Account for signed/unsigned native range semantics
When it happens
Trigger: Calling RangeValuePattern.SetValue(val) where val < Min (from the control's UDM_GETRANGE). E.g. setting 0 on a spinner whose minimum is 1, or passing a negative value into an all-positive range.
Common situations: Tests assuming spinners start at 0; app changed the spinner's Min; callers clamping against cached bounds; signed/unsigned mismatch with the native range.
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
- SR.RangeValueMax
- SR.InvalidParameter
- Argument out of range (end not contained in view)
- Argument out of range (position does not map to a line)
- Argument out of range (start not contained in view)
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/5d19e222842050a6.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsUpDown.cs:219
{
// Make sure that the control is enabled
if (!SafeNativeMethods.IsWindowEnabled (_hwnd))
{
throw new ElementNotEnabledException();
}
if (double.IsNaN(val))
{
throw new ArgumentException(SR.InvalidParameter);
}
if (val > Max)
{
throw new ArgumentOutOfRangeException("value", val, SR.RangeValueMax);
}
else if (val < Min)
{
throw new ArgumentOutOfRangeException("value", val, SR.RangeValueMin);
}
short newPos = Convert.ToInt16(val);
Misc.ProxySendMessage(_hwnd, NativeMethods.UDM_SETPOS, IntPtr.Zero, NativeMethods.Util.MAKELPARAM(newPos, 0));
// Scroll the buddy
Misc.ProxySendMessage(HwndBuddy(_hwnd), NativeMethods.WM_HSCROLL, NativeMethods.Util.MAKELPARAM(NativeMethods.SB_THUMBPOSITION, newPos), IntPtr.Zero);
}
// Request to get the value that this UI element is representing in a native format
double IRangeValueProvider.Value
{
get
{
return Pos;
}
}
View on GitHub (pinned to 81131a70a4)