{"record":{"id":"15ef224c1354e5a6","repo":"dotnet/wpf","slug":"sr-operationcannotbeperformed-windowsstatusbar","errorCode":null,"errorMessage":"SR.OperationCannotBePerformed","messagePattern":"SR\\.OperationCannotBePerformed","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatusBar.cs","lineNumber":524,"sourceCode":"            }\n\n            IRawElementProviderSimple IGridItemProvider.ContainingGrid\n            {\n                get\n                {\n                    return _parent;\n                }\n            }\n\n            #endregion Grid Pattern\n\n            #region Value Pattern\n\n            // Sets the text of the edit.\n            void IValueProvider.SetValue(string str)\n            {\n                // This is a read only element.\n                throw new InvalidOperationException(SR.OperationCannotBePerformed);\n            }\n\n            // Request to get the value that this UI element is representing as a string\n            string IValueProvider.Value\n            {\n                get\n                {\n                    return Text;\n                }\n            }\n\n            // Read only status\n            bool IValueProvider.IsReadOnly\n            {\n                get\n                {\n                    return true;\n                }","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatusBar.cs#L506-L542","documentation":"The status bar proxy exposes the Value pattern as read-only: IValueProvider.SetValue always throws InvalidOperationException with SR.OperationCannotBePerformed. Status bar text is owned by the application, so the automation proxy refuses writes to it.","triggerScenarios":"Calling IValueProvider.SetValue(string) on a Win32 status bar element obtained via UIA.","commonSituations":"Test scripts that attempt to set text on every Value-pattern-capable control generically; confusing a status bar with an editable text field; trying to 'fix' displayed status text during automation runs.","solutions":["Do not call SetValue on status bar elements; treat them as read-only and verify their Value instead.","Restrict SetValue calls to elements where IValueProvider.IsReadOnly is false.","If the text must change, drive the owning application's API/UI, not the pattern."],"exampleFix":"// before\nvaluePattern.SetValue(\"Done\");\n// after\nif (!valuePattern.Current.IsReadOnly) valuePattern.SetValue(\"Done\");","handlingStrategy":"validation","validationCode":"var vp = element.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;\nif (vp != null && !vp.Current.IsReadOnly) { vp.SetValue(text); }","typeGuard":"static bool IsWritableValue(AutomationElement e) { var v = e.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; return v != null && !v.Current.IsReadOnly; }","tryCatchPattern":"try { vp.SetValue(text); }\ncatch (InvalidOperationException) { /* element is read-only */ }","preventionTips":["Check IsReadOnly before SetValue","Treat status bars as read-only display elements"],"tags":["read-only","uiautomation","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}