{"record":{"id":"0e6ff2b8b53d3a0f","repo":"dotnet/wpf","slug":"sr-reshownotallowed","errorCode":null,"errorMessage":"SR.ReshowNotAllowed","messagePattern":"SR\\.ReshowNotAllowed","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs","lineNumber":3693,"sourceCode":"        internal void VerifyContextAndObjectState()\n        {\n            // Verify that we are executing on the right context\n            VerifyAccess();\n\n        // WCP Window:  Define the dispose behavior for Window\n#if DISPOSE\n            if (_disposed)\n            {\n                throw new ObjectDisposedException(null, SR.WindowDisposed);\n            }\n#endif\n        }\n\n        private void VerifyCanShow()\n        {\n            if (_disposed)\n            {\n                throw new InvalidOperationException(SR.ReshowNotAllowed);\n            }\n        }\n\n        private void VerifyNotClosing()\n        {\n            if (_isClosing)\n            {\n                throw new InvalidOperationException(SR.InvalidOperationDuringClosing);\n            }\n\n            if (!IsSourceWindowNull && IsCompositionTargetInvalid)\n            {\n                throw new InvalidOperationException(SR.InvalidCompositionTarget);\n            }\n        }\n\n        private void VerifyHwndCreateShowState()\n        {","sourceCodeStart":3675,"sourceCodeEnd":3711,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs#L3675-L3711","documentation":"VerifyCanShow throws InvalidOperationException with ReshowNotAllowed when Show/ShowDialog is called on a window that has been disposed (_disposed). A WPF window cannot be re-shown after it has been closed and disposed; each window instance is single-use once closed.","triggerScenarios":"Calling Show() or ShowDialog() on a window whose Close() has completed and whose resources were disposed.","commonSituations":"Caching a single window instance and re-invoking Show for repeated use (e.g. an About dialog); users closing the window then code calling Show again.","solutions":["Create a new window instance each time instead of re-showing a closed one.","Keep the window open (hide it with Hide() instead of Close()) if it must be reused.","Track the closed state and re-instantiate on demand."],"exampleFix":"// before\nif (_aboutWindow == null) _aboutWindow = new AboutWindow();\n_aboutWindow.Show(); // second Show throws after user closes it\n// after\nvar w = new AboutWindow(); // fresh instance\nw.Show();","handlingStrategy":"validation","validationCode":"bool canShow(Window w) => w != null && !w.IsDisposed(); // track disposal via Closed event or internal flag","typeGuard":null,"tryCatchPattern":"try { w.Show(); }\ncatch (InvalidOperationException) { w = new WindowType(); w.Show(); }","preventionTips":["Treat closed WPF windows as single-use; create new instances.","Use Hide() instead of Close() when a window must be reused.","Do not cache window instances across user closes."],"tags":["wpf","window","disposed","reshow"],"backgroundTag":"invalid-state-transition","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"}