© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
18 replies
Gipper

Windows crashing the program when attempting to reopen windows after having been closed once already

My MainWindow has some buttons which open other windows also in the project through a
app.view_name.ShowDialog();
app.view_name.ShowDialog();
command. If I click the button to open the problem windows and then close it, if I attempt to reopen by clicking the button once again I get this exception:
System.InvalidOperationException: 'Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed.'
System.InvalidOperationException: 'Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed.'
.
Of the four buttons in this MainWindow two of them are experiencing this crash, while the others aren't for some reason. Please tell me if there's any code you would like to see as I am more than happy to provide it, but there's just so much code that could be relevant to my inexperienced eyes I didn't know what to post.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ How to reopen solution explorer if been closed
C#CC# / help
4y ago
❔ Execute code when console app is closed on Windows?
C#CC# / help
4y ago