Solving the “Visual Studio needs to close” error

I have not seen this issue in quite some time, but lately I have seen quite a few posts on this issue, as more people are moving to Windows 7. So, it is time to post an entry and get the knowledge base out on the web.

Finding the Problem

As usual, there are numerous things that can cause Visual Studio to crash. Here is a list (most likely incomplete):

  1. Visual Studio Bug
  2. Program interfering with Visual Studio (usually a TSR)
  3. Driver causing issues with Visual Studio
  4. Corrupt Project file
  5. Corrupt User Profile
  6. Add-in problem in Visual Studio

The first step, with any troubleshooting is to find the source of the problem. Fortunately, the Visual Studio team thought of this eventuality. Start Visual Studio like so (from a VS command prompt or a normal command prompt if you have the denvenv.exe path in your system path):

devenv.exe /log

This will log to the following folder:

Visual Studio 2005:
%USERPROFILE%Application DataMicrosoftVisualStudio8.0ActivityLog.xml

Visual Studio 2008:
%USERPROFILE%Application DataMicrosoftVisualStudio9.0ActivityLog.xml

I don’t have a crash on this machine, but the file is a list of activities, including the loading of add ins. It looks like this:

<?xml-stylesheet type="text/xsl" href="ActivityLog.xsl"?>
    <time>2010/01/05 18:13:17.656</time>
    <source>Microsoft Visual Studio</source>
    <description>End package load [Visual Studio Common IDE Package]</description>
    <time>2010/01/05 18:14:54.687</time>
    <source>Microsoft Visual Studio</source>
    <description>Destroying Main Window</description>

When you crash, check the log out and see if there is anything that occurs right before the error message. This is most likely your offending party. If this does not help, at least note the add ins loaded, as they can be a source.

Now let’s look at solutions for the various reasons you can have a problem.

Visual Studio Bug

The best option here is make sure you have the latest patches to Visual Studio on your machine. Depending on what you are developing with, there may be additional patches. If, for example, you have Windows 7 and are using some of the newer bits (Silverlight 3 comes to mind, but I will have to check if it has a VS pre-requisite), you should go to the download site and check the add ins you have to make sure there are no pre-requisites. The same advice is true for other Windows OSs, but I remember some pre-reqs for Win7.

If you determine a VS bug, or at least highly suspect as you have ruled out other things, log the bug on Microsoft connect under the Visual Studio program (The connect site is

Program interfering with Visual Studio (usually a TSR)

The best way to determine if this is true is starting Windows in Safe mode and playing with Visual Studio. If it does not crash here it is either a TSR or a driver that is the problem child. Once you determine the program, update to the latest version/patch. If that does not work, inform the manufacturer of a bug.

Driver causing issues with Visual Studio

Once again, boot in safe mode to find this. Printer drivers have been known to cause VS problems, so that would be my first direction to head. To fix a driver, you have to update it. If it is an update that caused the issue, rollback and inform the manufacturer of the hardware in question.

Corrupt Project file

The best way to test the project file is to create a new project and start playing with it. If this does not cause any issues, then import the project files for the project in question and play. If no problem, overwrite the old project file. If you have this in source control (you do, right? – nod head up and down), then check out the current project file and overwrite. You may have to do the same for the solution file in some instances.

Corrupt User Profile

This is rare, I would assume, but Microsoft has acknowledged this happens. To test you need a new profile and then play with the file. If no problems, you have to get an admin to delete this profile and recreate it. If you are using the administrator profile (*pain from me smacking your hands*), then create a new profile and start developing there.

Add-in problem in Visual Studio

I have had problems with nearly every developer add in I have tried at some point in time. To test this, start Visual studio with devenv.exe /safemode and see if it occurs. If you have a problem, turn off the add ins and turn them on one by one until you find the problem child.

The solution is to patch the bit from the manufacturer to the latest patch. If this does not solve things, log an error with the manufacturer.

Can’t find the particular add in, or it is a corrupt Microsoft “add in”? Run devenv.exe /resetpkgs and reset the IDE. After this, you may have to reinstall some add ins, but if this cures the problem, you can add them in one at a time (most important first) and make sure there are no additional problems.

Peace and Grace,

Twitter: @gbworld


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: