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 🙂

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:


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.
  • 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!

Problem Steps Reporter

Surprisingly few software developers know psr.exe, the Windows built-in Problem Steps Reporter. It is a tool well suited to record some steps which lead to a problem in a software and share them with a developer.

  • It is so much easier to use the psr.exe than to write down step by step and make screenshots on the way.
  • Psr is so easy to use, everybody can use it and report problems with it. Even your uncle Sam, 87 years of age.
  • No installation needed. Psr is already there since Windows 7 at least.
  1. Click onto the start button
    Start button

  2. Type in psr.
  3. In the upcoming window, click psr at the top.
    Start menu

  4. The problem steps reporter starts.

  5. Click Start Record in the psr.
  6. Do the steps you want to report.
  7. Click Stop Record in the psr.
  8. A Save As window comes up. Save the recording somewhere where you will find it later.
  9. Send the zipped report to the developer by email.
  10. The developer will run the .mht file contained in the zip file by doubleclicking it.
  11. The MS Internet Explorer opens and shows the problem report, with every mouseclick, every dialog box and so on. Very very helpful for the developer.


Spy Tool !?

Psr has got a lot of command line options. You could start it automatically and without GUI. The user wouldn’t even notice that it was running. Which makes it sort of a spy tool, says annoyedadmin.
But IMO, psr would make a quite bad spy tool. Because

  • The keys pressed by the user are not visible.
  • Psr can maximally record 100 screen shots.

How to Convert Mht to Html

Mht is a Microsoft proprietary format which normally can only be opened by IE. But Goran Atanasijevic has written and GPLed the converter mht2htm.exe which can convert a mht to several htm-files. You can get it from sourceforge or from me. It works well.

Also, a Total Commander plugin for mht-files called MhtUnPack exists. I have not tested this one yet.

Fiddler: How to Add a Http Verb, a SOAP Action and a Duration Column

Fiddler is a terrific and free web debugger for any browser, system or platform. You can see much information about every http request that is made. But even better, you can set breakpoints and tamper with the content of a request before continuing.

If you are doing web development, you need to know Fiddler. If you are starting web development, you should invest an hour or more to install and learn about Fiddler. It is a very good investment of your time.

How to Add a Http Verb Column

What I’ve missed from the beginning is a column which shows me the http method (POST, PROPFIND, GET, …) of a request. Many thanks to A. Mackert for the following solution:

In Fiddler, select Rules/Customize Rules. Notepad opens, with some predefined custom rule stuff. Scroll down unto class Handlers.
Uncommment the five marked lines and save the file.


If you have an older version, close and reopen Fiddler. Closing and reopeneing is not needed with the latest versions of Fiddler. Look for the new column – called Method at the right and drag it to the left. Voilá, you have a nice column with the http verb.


How to Change the Editor for the CustomRules File

If you want to do more changes than just uncommenting some lines, it is better to use another editor than notepad. To change the editor, go to Tools/Fiddler Options…/ Tools/FiddlerScriptEditor and select your preferred editor. Notepad++ will do well for now. For extended stuff, there is a special FiddlerScript Editor available. The FiddlerScript Editor has got a built in class explorer which helps with Fiddler classes and types.

How to Add a Column for the Duration of the Request

You can add a column which shows the time in seconds from start to end of a request.

With a current Fiddler version (I’m using you must search for the class Handlers in the CustomRules-file and add the following snippet of code to the class:

public static BindUIColumn("Duration", 60)
function CalcDurationCol(oS: Session){
  var result = String.Empty;
  if ((oS.Timers.ServerDoneResponse > oS.Timers.ClientDoneRequest)) {
    var duration = oS.Timers.ServerDoneResponse -
     result = String.Format("{0:0.0000}",
  return result;

In some previous Fiddler version,   you could just search for m_ShowTTLB in the CustomRules-file and set the value to true.

How to Add a Column Containing the Start Time of the Request

In the CustomRules-file, in the class Handlers add the following snippet of code:

public static BindUIColumn("Starttime", 80)
function CalcStarttimeCol(oS: Session){
  var result = oS.Timers.ClientDoneRequest.ToString("HH:mm:ss.ff");
  return result;

The language used in the CustomRules.js is JScript.NET. So you can use all of .Net’s String.Format possibilities to format the output of the added columns.

How to Add a Column for the SOAP Action

I’ve copied this one from KorteAchternaam.

public static BindUIColumn("SOAP", 120)
function FillSoapAction(oS: Session) {
        if ((oS.oRequest != null)
                && (oS.oRequest.headers != null)
                && (oS.oRequest.headers.Exists("SOAPAction"))) {
            var action = oS.oRequest.headers.Item["SOAPAction"];
            return action.replace(/^.*\//, "").replace(/"/, "");
            return String.Empty;

Happy fiddling.