Visual Studio Debugger not Working Correctly

Lately, I had to debug a C# project on a computer of a colleague and the colleague was not available.

The problem was, I could not debug because the Visual Studio 2005 debugger there did not work right.

The symptoms are:

  • Messages like Cannot evaluate expression because the code of the current method is optimized or in german: Der Ausdruck kann nicht ausgewertet werden, da der Code der aktuellen Methode optimiert wurde in the variables windows (auto, local, watch windows).
  • Some functions or methods are not entered when trying to step into them via F11.
  • At some places, breakpoints can not be set.
  • Differences about the point of execution between the source code and the stack window.
  • Sometimes, when stepping out of a function, the point of execution that is shown is not what you’d expect.

Every experienced developer knows these symptoms: They ususally do occur when you are trying to debug a program that has not been built in the DEBUG mode. Of course I checked this and rebuilt all. No change. I rechecked it and cleared all manually and rebuilt again – just in case. No change.

I got some grey hair …. and after some time I found out that there are two different types of debug mode in this version of VS. One called pdb-only and one called full. Switching the debug mode to full solved all the problems. Here is how to do it:

  1. Go to the build tab of the project.
  2. Make sure that DEBUG configuration is selected.
  3. At the bottom of the tab, there is a button Advanced or Erweitert. Press the button.
  4. In the upcoming dialog, select full instead of pdb only
  5. Rebuild all.
  6. Happiness 🙂

debug-full-2

VS: Restore Missing Auto Window

Somehow, the Auto-Window in my MS VisualStudio 2005 vanished and I couldn’t get it back. MS says, it is available in the Debug/Windows-Menu. But it wasn’t for me. See this screenshot as evidence: Auto-1

After some time of searching the web without success, I had the saving idea. So…

This is how to get back a missing Auto window in VS2005:

  • Make sure you are in debugging mode.
  • In the menu, select Extras/Customize.
  • In the upcoming dialog select category Debugging. Auto-2
  • On the right, look for Auto and drag the icon to a toolbar and drop it there.
  • Close the Customize dialog.
  • Press the new button on the toolbar. It is only active, if you are in debugging mode.
  • Eureka! The Auto window is back!