WSOD in Windows Forms

Any windows forms developer might have come accross this error message while programming in Visual Studio 2005.

"One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes."

This is called as the White Screen of Darn (WSOD) and is considered wrongly by some as an error/bug with the desinger. It is actually an error in the user application that causes this.

Let us try to reproduce this before we learn more about this.

Open a Winforms Application in C#.
Add a button to the form.
Build the solution
Add a UserControl to the Solution.
On the UserControl add a checkbox.
Rebuild the solution
Drop the user control created from the toolbox on to the form
Delete the UserControl from the project.
Rebuild the solution.
close and open the form

You see a WSOD.

If you have followed these steps and you produced a wsod, by now you should have realized the cause of the WSOD. It clearly indicates that it is not a bug with the designer, but the form is missing a control and so the designer fails to load the form.

How can you go about resolving the problem ?
1. Add a new usercontrol with the same name again the project and rebuild the project. open and close the form. the form should be shown.
Option 1 is a good one when you know what has happened that caused the wsod. this is not the case when you are dealing with projects you got from somebody. In that case, you have to consider option2.
2. Comment out the lines in form1.designer.cs file which are the cause of the error. In this case the lines which reference UserContorl1.