It sounds like your solution settings were corrupted when Studio crashed. You can reset them by deleting your solution’s *.suo file:
- Make sure you can view hidden files
- Find your solution in Windows Explorer. It should be a
*.slnfile - There should be a hidden
*.suofile in the same folder. Delete it.
That will reset all of your solution-specific settings, including the windows you had open.
In the future, you can prevent code from executing in the designer by wrapping it in an if using the Form.DesignMode property (inherited from System.ComponentModel.Component):
if(!this.DesignMode)
{
/* put code to be excluded from the designer here */
}
UPDATE for VS 2017 and 2019
In VS 2017 and 2019, the *.suo file has been moved into a .vs folder within the solution directory:
~/[Solution Directory]/.vs/[Solution Name]/.suo
You can just delete the entire .vs folder to reset your local settings for that solution.