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