Thursday, October 28, 2010

Opening a Solution Causes VS 2005 to crash and restart

Earlier today, I had to include a code snippet to my project. Unrealizing the consequences it might result in, I went ahead compiling and got an error message saying “Object reference not set to an instance of an object” and finally my VS 2005 crashed. This error message keeps on greeting every time to I tried to reopen the project.

Being clueless of what has gone wrong, I googled tirelessly to find a solution to overcome this problem, but without a joy.

While this error message keeps on coming, I try to realize that my VS were actually running on debugging on all of my Windows forms. Since the Code snippet I included was to my base form’s shown event, so every time I reopen VS 2005 it opens this Windows Forms and sends this error message.
In the Error Signature I witnessed the following:

AppName: devenv.exe
AppVer: 8.0.50727.42
AppStamp:4333e699
ModeName: system.design.ni.dll
ModVer: 2.0.50727.3053
ModStamp:4889df30
fDebug:0
Offset: 006b8532

I came across an article on running devenv.exe in “Visual Studio 2005 Command Prompt” and was enlightened me that I could build, rebuild, clean…etc project and its files. So I went to Visual Studio’s Project folder and located the *.cs file which was giving the error and edited via Notepad. Then I deleted the code snippet that was the causing the problem and replaced by a simple “Hello World” message box. Finally I build the project by trying my luck via VS 2005 Command Prompt by running the following commands:


devenv [either *.csproj or *.sln file of your project] /clean


devenv [either *.csproj or *.sln file of your project] /build

devenv [either *.csproj or *.sln file of your project] /rebuild


and it worked! I was finally able to open the project via Visual Studio and it worked well… No errors!