Software Development

Fixing a hang while opening ASPX files in Visual Studio

Read about the strangest programming bug Justin James has encountered this year. He describes how a Microsoft technician helped him figure out what was causing the Visual Studio bug.

The strangest bug I've seen all year was with Visual Studio, a program that I ordinarily find to be quite stable and reliable, at least in versions 2008 and 2010. The problem that I faced was that, every time I opened an ASPX file from a particular solution, Visual Studio would hang and give the dreaded "Visual Studio is busy" error message. Usually when you see this error, it is a one-time event, and it really means "Visual Studio is dead." In this case, though, if I left it alone for 5 to 90 minutes, the program would suddenly come back to life.

Digging deeper into the problem, I discovered all sorts of clues, but nothing that lead to a solution. These are some of the things that were happening:

  • It would hang when adding an empty ASPX to the solution.
  • It would hang if you opened an ASPX in that solution directly from Windows Explorer.
  • It would hang if I copied the solution's contents outside of my TFS working directories.
  • It did not hang with any other projects.
  • It hung on Visual Studio 2010 on another person's machine, but not on a third developer's machine (the one who had originally been working with the project).
  • When it was hung, CPU usage was 0%, RAM usage was not changing, and there was no network traffic occurring, so it did not look like an ordinary deadlock.
  • The problem was random; sometimes you could open an ASPX file just fine, and other times the hang would occur.
  • The problem would not occur if I copied one of the "problem ASPX" files outside of the solution's file structure and opened it.

I ruled out TFS issues, problems specifically with a reference to a particular Web Part, a library, or the Master Page, or issues specific to those ASPX files, since the problem would come up even with a blank ASPX file.

After a few days of being completely paralyzed by this problem (the project had been handed off to me, and we had a ton of things for me to do), I eventually opened a ticket with Microsoft. It pains me to do this because I'm admitting that I can't solve the problem. In this case, there were so many different reasons to see this message, and none of them quite fit my situation, that it was simply quicker to engage Microsoft. And given what my time is worth to my employer and what a Microsoft ticket costs, the ticket is usually a bargain compared to wasting my time.

The Microsoft technician I worked with was quickly stumped. We went through all of the scenarios where it would occur and where it wouldn't. Eventually, he worked with me to generate a dump file. The very next day, he found the problem!

Visual Studio's Design mode requires that the components on a page be initialized so that they can be rendered properly. Some of the components on some of the pages were trying to access a database that was not available from my machine (or the other machine with the problems) during their initialization. When these components underwent initialization, Visual Studio would hang trying to connect to the database, and it would hang for a very long time instead of having a timeout around that initialization. In addition, Visual Studio will pre-initialize components, and that is why it was hanging even when working with an empty ASPX file.

Lesson learned

I am passing on this information in case any TechRepublic readers encounter this bug. If opening ASPX files hangs Visual Studio (versions 2008 or 2010), look carefully at the initialization code of the components in your project because this could very well be the culprit.

I hope this helps someone else before they lose days of work to this issue.

J.Ja

Disclosure of Justin's industry affiliations: Justin James has a contract with Spiceworks to write product buying guides; he has a contract with OpenAmplify, which is owned by Hapax, to write a series of blogs, tutorials, and articles; and he has a contract with OutSystems to write articles, sample code, etc.

About

Justin James is the Lead Architect for Conigent.

7 comments
podoyle
podoyle

Which solution did you choose?

Tony Hopkinson
Tony Hopkinson

from the IDE is irritating, it pales into insignificance compared to design time initialisation from a database. That's just asking for it.

Sterling chip Camden
Sterling chip Camden

introduce unnecessary complexity to the dev process. Give me vim and a command line - I'd rather debug only my own code, not Microsoft's too.

Justin James
Justin James

I made a local copy of the DB (it was huge, too) and changed the web.config on my development machine to point to it. J.Ja

apotheon
apotheon

I made a similar (but wordier) comment to Justin's poll article that referred to this problem.

apotheon
apotheon

That was the first thing I thought of when you mentioned in the article what the MS support person told you was the source of the problem.

Editor's Picks