Groups | Blog | Home
all groups > dotnet clr > august 2005 >

dotnet clr : VS debugger stopped working


Mikael Östberg
8/18/2005 10:17:14 AM
Hello all!

I have been working on a project for some time now and yesterday, my
debugger stopped working.
It is a class library which I run from a Win32 test app, so no IIS involved
at this point.

I can still set breakpoints and when debugging the breakpoints get hit -
just like it would work normally.

However, when I want to check values of objects and such using autos or
watch, all values are null. I can step through the code, but it seems like
the debugger does not care about the code. It steps into catch blocks even
though an exception would be impossible. It would even step into this
statement:

string test = null;
if(test != null) {
// it would step into here
}

Here is an image that proves this wierd condition:
http://www.inloop.se/temp/debugger.jpg
This example is a standard Win32 app with only one form and one button.

I have run the repair feature in Visual Studio. I have also re-installed the
..Net framwork 1.1 SP1 for Win2003 but that didn't help.

Has anyone seen this before? What could possibly had happened and more
importantly, how can I solve this?

Thanks!

Mikael Östberg

Nick Hertl
8/23/2005 2:36:25 PM
This can easily happen if the source has changed since the last time
you compiled your application.

If for example you began with this:

------
string test1;
string test2;



[some other initialization code here]


try
{
}
catch (Exception e)
{
Console.WriteLine(e);
}
-----

You compile this, but then change the source to something like this
instead and then debug without recompiling:

------
string test1;
string test2;
try
{
}
catch (Exception e)
{
Console.WriteLine(e);
}
-----

The result is that the debugger thinks it has stepped through all that
code that used to be there and is just reporting the line number that
used to go with that, but since it's changed since then it no longer
matches.

Now how could this have actually happened?

Usually VS will not even let you start debugging without re-compiling
first, so chances are good that something is preventing the compile
from completing and this is getting ignored. Maybe you have an error
in your code or perhaps some other file has a lock on the files that
you are trying to compile to.

Another possibility is that you have set your project up as a "Retail"
project which can make debugging very painful.

What I would recommend is the following:
Look at the files that you think you are running and check out the date
and time they were last modified. If it seems like too far in the
past, this is likely the problem. If it really is totally recent, then
look for a matching file with the same name but ending in pdb instead
of exe and see if it is also new.
I'm guessing that you will find at least one of these files is older
than you think it should be because it's not getting compiled correctly
before you begin debugging.

I hope that this advice helps. Please re-post if you are still having
trouble.
Mikael Östberg
8/24/2005 12:00:00 AM
In my efforts to solve this, I started a completely new project which
consists only of a C# Windows Application through the New Project Wizard.

In other words: The class library is put aside for now and I'm trying to
solve this by performing tests in a clean C# Win32 app. The problem is
reproduced in this project as well (as well as in VB.NET).

This image(http://www.inloop.se/temp/debugger.jpg) is a screenshot from that
project and as you can see the string are null even though the debugger has
stepped through the code. Another odd thing is that the debugger went into
the catch block and instantiated an empty(I guess) exception.

In the debug output window, I can see that the symbols for my application
are loaded for the exe:

'WindowsApplication3': Loaded 'C:\Documents and Settings\mikaelo\My
Documents\Visual Studio
Projects\WindowsApplication3\bin\WindowsApplication3.exe', Symbols loaded.

Yet another thing to point out is that I can debug the class library I was
working on using an ASP.NET application as an entry point. Win32 debugging
does not work but ASP.NET debugging does.

What is the difference between these two debugging methods? I can think of
stuff like they are being run as different users and different processes.
But what I don't know is what differs between the two in terms of what they
use to perform their tasks. Somehow the Win32 one has gone mad.

I don't know if it has anything to do with this, but when this first seized
working, I was using the WebClient class alot. I was also using edit and
continue as well which caused VS to hang for some reason (maybe due to open
connections or something). It was sometime during this time, this problem
occured the first time. But it would seem strange if you could break the
debugger by abusing it a bit.

Thanks!

Mikael Östberg

[quoted text, click to view]

Nick Hertl
8/29/2005 1:40:50 PM
When you type in:
dir "C:\Documents and Settings\mikaelo\My Documents\Visual Studio
Projects\WindowsApplication3\b=ADin"

Look at the time-stamp that these files were most recently modified.
Does this time-stamp make sense to you? Does it match the last time
you tried to run your application in the debugger or is it from a long
time ago?

If it's recent, then I'm not sure what the problem may be without more
information, but I suspect it will be old. In that case, you may want
to figure out why it's so old and doesn't match your source.
AddThis Social Bookmark Button