I was happily using VB.NET, saved, and, well, there was a blackout.
Probably lucky? Well, now I open my project just fine, double click the Form1.vb and…. “There is no editor available for ../Form1.vb, make sure the application for the file type (.vb) is installed.”
………. Did something go wrong with my project? Is it dead?
Windows 7, Visual Basic 2010 Express.
What should I do?
It’s difficult to imagine what you’re seeing. I’ve seen plenty of cases where the design view won’t open for whatever reason, but I’ve never been unable to view the code for the form.
First thing to try is navigating to your project folder in Windows Explorer, right-clicking on the
Form1.vbfile, and trying to open it in Notepad. This is pretty much the ultimate test. If you can open it in Notepad, your work is salvageable. If not, the file is corrupted and your best bet is to start over. I suppose if you really feel that you have a lot invested, you could try various file recovery techniques, but considering it’s a single form file, I seriously doubt it’s worth the time or expense.If that succeeds, and you can open the file in Notepad, select all the code and copy it to the clipboard. Now go back into Visual Studio, and add a new
Formto your project. Delete everything in the new form’s code file and paste the salvaged code from your original form back in. You still won’t be able to open the form in the designer though, and you’ll likely be missing references to all of your controls. Ignore all those squiggly underlines for now.To fix that, you need to go back to Windows Explorer, and find a file named
Form1.Designer.vb. This is the partial class that the designer saves information into; it contains declarations for all of your controls and the properties you set for those controls at design time. Just as before, right-click on this file and open it in Notepad. Select everything and copy it to the clipboard. Now go back to Visual Studio, and click on the “Show All Files” button at the top of the Solution Explorer (hover over them to read the ToolTips). You’ll see a bunch of extra junk show up, but what you’re primarily interested in are the drop-down arrows that just appeared to the side of everyFormclass. Expand the new form you added in the previous step, and find it’s.Designerfile. Delete everything that’s in there now, and paste in the code from your salvaged form’s.Designerfile.You now have an exact copy of your old form in your project. You can delete that old, corrupted form file, because you’re no longer using it. You’ll also probably want to change the name of the new file itself by right-clicking on it in the Solution Explorer—right now, it’s named
Form1just like your old form, because it’s an exact copy of that form. The code says it’s name isForm1and couldn’t care less about your file name. Clean and rebuild your project, and if things go your way, everything should be back to normal.