{"record":{"id":"4664db6041b76017","repo":"dotnet/wpf","slug":"sr-valuereadonly-windowsprogressbar","errorCode":null,"errorMessage":"SR.ValueReadonly","messagePattern":"SR\\.ValueReadonly","errorType":"exception","errorClass":"System.InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsProgressbar.cs","lineNumber":86,"sourceCode":"        //\n        //------------------------------------------------------\n\n        #region ProxySimple Interface\n        \n        // Returns a pattern interface if supported.\n        internal override object GetPatternProvider (AutomationPattern iid)\n        {\n            return (iid == RangeValuePattern.Pattern) ? this : null;\n        }\n\n        #endregion\n        \n        #region RangeValue Pattern\n\n        void IRangeValueProvider.SetValue (double val)\n        {\n            //This proxy is readonly\n            throw new InvalidOperationException(SR.ValueReadonly);\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                return (double)ValuePercent;\n            }\n        }\n\n        bool IRangeValueProvider.IsReadOnly\n        {\n            get\n            {\n                return true;\n            }\n        }","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsProgressbar.cs#L68-L104","documentation":"WindowsProgressbar proxies the Win32 progress bar control, whose value can only be set by the control's owner application, not by UI Automation clients. The IRangeValueProvider.SetValue implementation is intentionally read-only and throws InvalidOperationException(SR.ValueReadonly) to tell the caller that this property cannot be modified through UIA.","triggerScenarios":"Calling UIA RangeValuePattern.SetValue(value) on a progress bar element backed by the WindowsProgressbar proxy.","commonSituations":"Test or automation code that tries to 'set' progress bar progress to simulate state, confusing progress bars with sliders (which do support SetValue via RangeValue pattern).","solutions":["Do not set progress bar values via UIA; drive the underlying application so it updates the progress itself","If you need a settable range element, target a slider/trackbar control instead","Read the current progress with RangeValuePattern.Value, which is supported","Update test logic to verify progress rather than set it"],"exampleFix":"// before\nvar range = progressBar.GetCurrentPattern(RangeValuePattern.Pattern) as RangeValuePattern;\nrange.SetValue(50); // throws InvalidOperationException\n// after\nvar range = progressBar.GetCurrentPattern(RangeValuePattern.Pattern) as RangeValuePattern;\ndouble progress = range.Value; // read-only: observe instead of set","handlingStrategy":"validation","validationCode":"bool IsRangeValueSettable(AutomationElement e) { var p = e.GetCurrentPattern(RangeValuePattern.Pattern) as RangeValuePattern; return p != null && !e.Current.Name.Contains(\"progress\") && e.Current.ClassName is string cn && cn.IndexOf(\"progress\", StringComparison.OrdinalIgnoreCase) < 0; }","typeGuard":"bool IsSettableRange(AutomationElement e) => e.TryGetCurrentPattern(RangeValuePattern.Pattern, out var p) && !IsProgressBar(e);","tryCatchPattern":"try { rangePattern.SetValue(v); } catch (InvalidOperationException) { /* progress bar is read-only: observe with rangePattern.Value instead */ }","preventionTips":["Treat progress bars as read-only in UIA; only sliders/trackbars support SetValue","Read progress via RangeValuePattern.Value, never write it","Check e.Current.ClassName/ControlType (ProgressBar) before attempting SetValue"],"tags":["uiautomation","readonly","progress-bar","invalid-operation"],"backgroundTag":"operation-not-supported","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"}