VB.NET - Loss of Form - Asked By Vijay Rajdhan on 21-Mar-12 11:03 AM

I posted two posts on my problem.. . wonder how it can be resolved. Please help if  there is a possible solution to retrieve the lost form.

My two posts of today specify  the problem :--

Post No 1.
In a multi-form vb.net application, Form7 which opened with a button on Form6 has all of a sudden stopped showing during run time. Trying to open the form with help of browser, neither the code nor the designer pages open. The Form7 seems to have disappeared without a trace..... Please help... how to avoid this in future?.. and will it be possible to retrieve the lost form somehow?

Post No 2
Now there is more surprise in store. After shutting down the machine I  restarted the Visual Studio2008 application and attempted to run the same program. The debugger started fine and and all links worked well up to Form6. I crossed my fingers if Form7 would open on clicking the 'Next' Button on Form6. To my surprise Form7 did open as usual. Reverting to the Solution Browser to open Form7 Designer, I ran into the same old problem... no trace of Form7. 

Trying to troubleshoot, I searched in all drives for form7 if it had been saved elsewhere due to some error. Nothing came up from this search. But then why does the Form7 run while debugging... it has to be somewhere on the machine for it to open after Form6. It beats all logic. 
LIJO PHILIP replied to Vijay Rajdhan on 13-Apr-12 02:20 AM
1. As your designer and code is gone there is no way to get it back.

2.As my experience base extends I've learned several things.

1.) Always Back up your project.

2.) Forms get corrupted from time to time. Sometimes the IDE just gets confused. Sometimes you can fix it. I'll discuss this a little bit below.

 What the files are:

 FormX.VB contains the source code for the form. Rarely if even gets corrupted.


 Normally this is not too interesting of a file except when it becomes corrupted. This file controls the definition for all designer created controls on a form. This is the least robust of the three files and this is the file where the designer most often becomes confused. It is also repairable. Once your project is designed it's a very static file and just doesn't change.


 This file is rarely corrupted but when it corrupts it's not fixable. It is a resource file and usually has image data stored in base 64. It is usually a very static file. The only ways to recover from damage to this file is:

 1.) via back up

2.) If you have no backup, create an empty project with a form having the same name. Close main project. rename the corrupted FormX.resx file. Copy the new one into your directories. You have now lost all of your resources but they can be manually reinstalled.

 Back to FormX.Designer.VB

 I mentioned that this is a boring file to read but functionally it's not boring at all. I have a very complex two year old project and I'm rewriting it. Making a new front form is a minimum of two days work. I couldn't just copy all of form1 because it's full of complex code and it would be undesirable to start with anything but a new project.

 So I started a new project and copied form1.resx and form1.designer.vb and viola... my blank project had all controls and resources including image lists of the old project!!!! This file is editable IF you know what you are doing. When this file becomes corrupted, usually chunks of the file are missing or duplicated. Sometimes content is lost.

The next time you have a project that becomes corrupted, consider this.

Vijay Rajdhan replied to LIJO PHILIP on 13-Apr-12 05:29 AM
Thanks a lot for your interest in my problem and the work-around suggested
to fix the issue.

I shall really preserve your suggestion just in case I run into similar situation.
However keeping a back-up is the most sensible and easiest thing to do.

Thanks a million.... Aye...

Colonel Vijay Rajdhan