dotnet/wpf · error · ArgumentOutOfRangeException
Specified argument was out of the range of valid values…
Error message
Specified argument was out of the range of valid values. (Parameter 'value') Value is greater than Maximum.
What it means
WindowsIPAddress's IRangeValueProvider.SetValue throws ArgumentOutOfRangeException when the requested value exceeds the RangeValue Maximum of 255 — each octet of an IPv4 address must be 0–255. The UI Automation client attempted to set an octet above its maximum.
Solutions
- Clamp the value to 0-255 before calling SetValue
- Check RangeValuePattern.Maximum (should be 255) before setting
- Catch ArgumentOutOfRangeException and reject the input
- Split larger numbers appropriately across octets (IPv4 semantics)
Example fix
// before rangeValue.SetValue(300); // after int octet = Math.Clamp(300, 0, 255); rangeValue.SetValue(octet);
Defensive patterns
Strategy: validation
Validate before calling
int octet = (int)val; if (octet < 0 || octet > 255) throw new ArgumentOutOfRangeException(nameof(val), val, "Octet must be 0-255.");
Try / catch
try { rangeValue.SetValue(val); }
catch (ArgumentOutOfRangeException) { /* clamp to 0..255 or reject input */ } Prevention
- Clamp values with Math.Clamp(v, 0, 255)
- Check RangeValuePattern.Minimum/Maximum before setting
- Remember octets are bytes, not ports
- Validate test data for out-of-range octets
When it happens
Trigger: Calling IRangeValueProvider.SetValue with val > 255, e.g. 256, 999, or a double like 300.5 cast to int, on an IP address octet field.
Common situations: Assuming the field range is 0-65535 (port-like) instead of 0-255; passing byte-encoded values unclamped; test data with invalid octets like "999.1.1.1".
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
- Specified argument was out of the range of valid values…
- Specified argument was out of the range of valid values…
- Specified argument was out of the range of valid values…
- SR.GridColumnOutOfRange
- SR.GridRowOutOfRange
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/1a50ed7b0f9a393c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsIPAddress.cs:372
#endregion
#region RangeValue Pattern
// Sets the one of the field of the IP Address.
void IRangeValueProvider.SetValue(double val)
{
// Make sure that the control is enabled
if (!SafeNativeMethods.IsWindowEnabled(_hwnd))
{
throw new ElementNotEnabledException();
}
int i = (int)val;
// Check range
if (i > 255)
{
throw new ArgumentOutOfRangeException("value", val, SR.RangeValueMax);
}
if (i < 0)
{
throw new ArgumentOutOfRangeException("value", val, SR.RangeValueMin);
}
// Set text
Misc.ProxySendMessage(_hwnd, NativeMethods.WM_SETTEXT, IntPtr.Zero, new StringBuilder(i.ToString(CultureInfo.CurrentCulture)));
}
// Request to get the value that this UI element is representing in a native format
double IRangeValueProvider.Value
{
get
{
string s = WindowsEditBox.Text(_hwnd);
if (string.IsNullOrEmpty(s))
{View on GitHub (pinned to 81131a70a4)