KnowDotNet

Rebuilding a RESX File

by Les Smith

How can I rebuild a RESX file when the Forms Designer will not show my form?  I have seen this question on the Microsoft Newsgroups many times and it has happened to me.  For some unknown reason, the Windows Form Designer will not display a form.  The .VB or .CS file is fine, and the application will build, but the Form Designer will not display the form.  The .RESX file is somehow corrupted, and you get the following error message, "An error occurred while loading the document. Fix the error, and then try loading the document again."

You can rebuild the .RESX file with the following procedure.

1. Go to Windows Explorer and make a copy of the bad forms .RESX file.
2. In the Solution Explorer, click the Show All Files button.
3. Your form should have a + beside it.  Click it and the .resx should show. Make a copy of the .resx file.
4. Right click on the .resx and delete it.
5. Close the IDE.
6. Restart VS and load your project, the .resx should be ok.

This has worked for me on numerous occassions, but make sure you make a copy of the resx before deleting it so that you won't be mad at me if this fails.  This same procedure will work in VB.NET and in C#.