dotnet/wpf · error · InvalidOperationException

SR.ReshowNotAllowed

Error message

SR.ReshowNotAllowed

What it means

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.

Solutions

  1. Create a new window instance each time instead of re-showing a closed one.
  2. Keep the window open (hide it with Hide() instead of Close()) if it must be reused.
  3. Track the closed state and re-instantiate on demand.

Example fix

// before
if (_aboutWindow == null) _aboutWindow = new AboutWindow();
_aboutWindow.Show(); // second Show throws after user closes it
// after
var w = new AboutWindow(); // fresh instance
w.Show();
Defensive patterns

Strategy: validation

Validate before calling

bool canShow(Window w) => w != null && !w.IsDisposed(); // track disposal via Closed event or internal flag

Try / catch

try { w.Show(); }
catch (InvalidOperationException) { w = new WindowType(); w.Show(); }

Prevention

When it happens

Trigger: Calling Show() or ShowDialog() on a window whose Close() has completed and whose resources were disposed.

Common situations: 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.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/0e6ff2b8b53d3a0f. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs:3693

        internal void VerifyContextAndObjectState()
        {
            // Verify that we are executing on the right context
            VerifyAccess();

        // WCP Window:  Define the dispose behavior for Window
#if DISPOSE
            if (_disposed)
            {
                throw new ObjectDisposedException(null, SR.WindowDisposed);
            }
#endif
        }

        private void VerifyCanShow()
        {
            if (_disposed)
            {
                throw new InvalidOperationException(SR.ReshowNotAllowed);
            }
        }

        private void VerifyNotClosing()
        {
            if (_isClosing)
            {
                throw new InvalidOperationException(SR.InvalidOperationDuringClosing);
            }

            if (!IsSourceWindowNull && IsCompositionTargetInvalid)
            {
                throw new InvalidOperationException(SR.InvalidCompositionTarget);
            }
        }

        private void VerifyHwndCreateShowState()
        {

View on GitHub (pinned to 81131a70a4)