How do I collect the call stack of Visual Studio's Main Thread?


When the GUI locks up (hangs, freezes) in Visual Studio, one important diagnostic step is to check the call stack of the "Main Thread" (the GUI thread). To collect this call stack from a hung instance of VS, you can use a second instance of Visual Studio:

  1. Start a second instance (a "new window") of Visual Studio.

  2. Close any open solutions in the new instance of VS.

  3. Select "Debug -> Attach to Process".

  4. Select the original hung instance of devenv.exe from the list of "Available Processes".

  5. Select "Debug -> Break All".

  6. Make sure you have the "Debug Location" toolbar enabled.

  7. From the "Thread" drop-down menu in the "Debug Location" toolbar, select the "Main Thread".

  8. Open "Debug -> Windows -> Call Stack". If the Call Stack contains any lines that say "[External Code]", right-click "[External Code]" and select "Show External Code" from the context menu before copying the information.

  9. Once you see the full call stack, select all the lines and copy and paste them into a text file.

Last Updated: Mar 24, 2016 07:18PM EDT