{"record":{"id":"1a50ed7b0f9a393c","repo":"dotnet/wpf","slug":"specified-argument-was-out-of-the-range-of-valid-values-1a50ed","errorCode":null,"errorMessage":"Specified argument was out of the range of valid values. (Parameter 'value') Value is greater than Maximum.","messagePattern":"Specified argument was out of the range of valid values\\. \\(Parameter 'value'\\) Value is greater than Maximum\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsIPAddress.cs","lineNumber":372,"sourceCode":"        #endregion\n\n        #region  RangeValue Pattern\n\n        // Sets the one of the field of the IP Address.\n        void IRangeValueProvider.SetValue(double val)\n        {\n            // Make sure that the control is enabled\n            if (!SafeNativeMethods.IsWindowEnabled(_hwnd))\n            {\n                throw new ElementNotEnabledException();\n            }\n\n            int i = (int)val;\n\n            // Check range\n            if (i > 255)\n            {\n                throw new ArgumentOutOfRangeException(\"value\", val, SR.RangeValueMax);\n            }\n            if (i < 0)\n            {\n                throw new ArgumentOutOfRangeException(\"value\", val, SR.RangeValueMin);\n            }\n\n            // Set text\n            Misc.ProxySendMessage(_hwnd, NativeMethods.WM_SETTEXT, IntPtr.Zero, new StringBuilder(i.ToString(CultureInfo.CurrentCulture)));\n        }\n\n        // Request to get the value that this UI element is representing in a native format\n        double IRangeValueProvider.Value\n        {\n            get\n            {\n                string s = WindowsEditBox.Text(_hwnd);\n                if (string.IsNullOrEmpty(s))\n                {","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsIPAddress.cs#L354-L390","documentation":"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.","triggerScenarios":"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.","commonSituations":"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\".","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)"],"exampleFix":"// before\nrangeValue.SetValue(300);\n// after\nint octet = Math.Clamp(300, 0, 255);\nrangeValue.SetValue(octet);","handlingStrategy":"validation","validationCode":"int octet = (int)val;\nif (octet < 0 || octet > 255) throw new ArgumentOutOfRangeException(nameof(val), val, \"Octet must be 0-255.\");","typeGuard":null,"tryCatchPattern":"try { rangeValue.SetValue(val); }\ncatch (ArgumentOutOfRangeException) { /* clamp to 0..255 or reject input */ }","preventionTips":["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"],"tags":["uiautomation","argumentoutofrange","rangevalue","max"],"backgroundTag":"value-out-of-range","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}