Wednesday, October 27, 2010

Visual Studio 2008 Detaching from the Debugger

At work, my machine has always been problematic. Getting Visual Studio 2008 to stay attached to the debugger has been an excercise in futility. I've done everything that every site on Google suggested. And still, a few seconds into debugging an ASP.NET web app under IIS or WebDev, the debugger would detach.

Note: This happens for me under Windows 7, against both IIS 7 and Visual Studio's WebDev.

  1. I was running Visual Studio as an administrator. I made sure of this by setting the shortcut properties, and even right-clicking the icon and selecting "Run as Administrator."
  2. I set up exclusions in the antivirus software to tell it not to scan my web project's folders.
  3. I disabled protected mode in Internet Explorer.
  4. I added localhost to the trusted sites in IE.
  5. I set the TabProcGrowth setting to 0 in the registry to disable IE's LCIE.

Still, the debugger would predictably detach. And then, the day before yesterday, I stumbled across something very, very curious. Windows Defender was still running on my machine.

Now that struck me as very odd, because my understanding is that you're not supposed to run two different antivirus packages at the same time: they'll wreak havoc with each other. So, I contacted IT and we decided it was time to shut that blasted thing off in favor of our preferred antivirus application. (Note that the antivirus application should have shut it off when it installed, but didn't for some reason.)

Once I did, Visual Studio fired up, and for the first time the word "(Administrator)" appeared in the title bar. That was the first clue that something drastic had changed. And the best news is that I haven't had a single disconnect from the debugger since.

I can't guarantee that this is the problem that you're having, but you might want to look at it. If you're running an antivirus application on your machine, Windows Defender should not be running at the same time.

To Disable Windows Defender

  1. Right click on My Computer.
  2. Select Manage.
  3. Click Services and Applications.
  4. Click Services.
  5. In the services list, double-click Windows Defender.
  6. In the Windows Defender Properties dialog, change the settings as follows:
    1. Change the Startup Type to Disabled.
    2. Click the Stop button.

    Click OK to close the dialog.

  7. Close Computer Management.

I hope this helps someone besides me, who's been battling this issue for months.