Thursday, 1 October 2009

(FIX) Visual Studio hangs, crashes and restarts when opening .ASPX or .ASCX files

So I come in to work, do my morning SVN update, open my Visual Studio 2008 solution and the aspx file I was working on the previous night hangs, crashed and restarts... errr WTF?!?

After doing this with every .aspx and .ascx file I opened I decided to abandon VS and use Notepad++... this was NOT a good solution! What made it even stranger is that I could open the same aspx/ascx files in a different VS solution and they'd open fine - no crashes, no restarts.

Stuck in VS hell for a couple days I thought ok let's take some time to figure this out. I googled some fixes, first I found a few suggestions on StackOverflow, then a hotfix update for an ASP.NET with MVC bug but I still couldn't resolve the issue. Then I reinstalled VS - made me lose my keyboard and environment
settings but I still had the crash/restart problem.

FINALLY I did something clever, instead of just watching the crash I debugged into it which gave me a null reference error in some shared code. Essentially another dev had been working on a shared project which was checking for an entry in the root web config:

var configEntry = System.Configuration.ConfigurationManager.GetSection("DumbAss") as NameValueCollection;

I had updated SVN at a project level so I got the shared change but missed the root web config update - I mean how often does the thing change anyway!

Essentially this hang, crash, restart issue is not always a Visual Studio problem (although it could handle it better). If like me you're stuck and need VS up and running check your web.configs are up-to-date with all the required config sections and if you're still getting VS restarting it's a good idea to step in with debug mode so you can see the real error that's being thrown.

1 Comments:

Anonymous Anonymous said...

What worked for me in VS 2005 was to Right-Click the file, hit "Open with..." and select the "User Control Editor with Encoding" instead of "User Control Editor (Default)".

21 May 2010 at 17:31  

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home