Home > Back-end >  Visual Studio JIT Debugger hangs
Visual Studio JIT Debugger hangs

Time:12-09

I've always used System.Diagnostics.Debugger.Launch() as a quick way to debug web services. I get a dialog asking me to choose a debugger, I pick "New instance of Visual Studio" and it fires up VS and lets me step through the code.

That has suddenly stopped working. Now I get the dialog, and choose Visual Studio, and the VS splash screen appears, and then it just hangs. The dialog window says "Not Responding" and I have to force it to close. Even then, a VS instance is left hanging around in Task Manager and I have to kill it manually.

I've tried repairing Visual Studio, and uninstalling and reinstalling Visual Studio, and nothing fixes it.

In desperation, I completely flattened my PC and reinstalled everything from scratch. It lasted about a day and then JIT debugging started hanging again. I was on Windows 10 and Visual Studio 17.4.1 before, and I'm on Windows 11 and Visual Studio 17.4.2 now.

To make sure that it's not a problem with some particular code, I created a one-line console app System.Diagnostics.Debugger.Launch(); and that crashes just the same.

Has anybody experienced anything similar, or have any idea what could be going wrong?

CodePudding user response:

I don't know why that fails, but I suggest to attach to a running instance of Visual Studio instead. Start Visual Studio first, and then when the "launch debugger" window appears, select the running VS instance. Preferably, you should even open the correct solution/project first. If you attach to that instance, all your source code and the project structure is available for debugging.

Another alternative: Instead of using Debugger.Launch(), use a code snipped such as

while (!Debugger.IsAttached)
{
    Thread.Sleep(100);
}

at the beginning of your program and attach the debugger from within Visual Studio (using the menu option Debug->Attach to process)

  • Related