Odd debugging behaviour - anyone else?

axum

Freshman
Joined
Mar 28, 2003
Messages
40
Hi, recently i have experienced some odd behaviour using the .NET IDE.

Running through the contents of a Hashtable and checking (using if Hash.Contains()) whilst i was stepping through the code it looked as though it was running BOTH the if AND the else statement!!

Also, the debug line often jumps into the "catch" area of a try/catch and seemingly runs the code within....when actually it doesn't get run at all....

This is making debugging difficult, and i wondered if anyone else had experienced similar problems?

Thanks

Axum
 
axum, I have also experienced this problem, I spent 2 hours this friday thinking I was experiencing an error, when in actual fact it was just the debugger jumping into the catch area and not actually running the line it has highlighted.

Out of interest what version of the .NET IDE are running?
 
i know what a NIGHTMARE!!!!

I'm currently debugging using C# as my codebehind....what language are you using?

It's really off-putting especially as it was running through both conditions of an if statement!!

How do i find out version? on the Help > About?

MS Development Environment - Version 7.0.9466

MS .NET Framework 1.0 - Version 1.0.3705

and you?

Axum
 
I was using C# codebehind, and

MS Development Environment - Version 7.0.9466
MS .NET Framework 1.0 - Version 1.0.3705

will look if it occurs in other areas of the IDE for example Windows Forms, and will also check another version of the IDE.
 
that would be great...get back to me if you find anything more out...

I DON'T think this happens when using VB.NET as your codebehind language, which is quite odd...

Axum
 
After abit of searching I have found the answer on a post on http://www.gotdotnet.com/team/csharp/learn/whitepapers/_Toc31512975

extract...

Consider the following code

string someStr;
someStr = "SomeValue";
if(someStr == null)
Console.WriteLine("what's up?");

try
{
}
catch(Exception e)
{
}

If you step through this code, you will see that when you step into the "if" statment, the instruction pointer is moved to the body("Console.WriteLine("what's up?");") of the "if" statement.
This is not debugger bug, it is known issue with try catch block debug information. See the followingdisasembled code

if(someStr == null)
0000002a cmp dword ptr [ebp-18h],0
0000002e jne 0000003C

Console.WriteLine("what's up?");
00000030 mov ecx,dword ptr ds:[01C50070h]
00000036 call dword ptr ds:[02F0257Ch]
0000003c jmp 00000048

catch(Exception e)
0000003e mov dword ptr [ebp-1Ch],eax
00000041 call 762C0846
00000046 jmp 00000048

}
00000048 nop

When the value is not matched, the instruction pointer is moved to "3c" line, but the line is mistakenly matched with the body of "if" statement. While the code functions correctly, the appearance is incorrect.
 
hmm, not really sure as my understanding doesn't go that deep, although i think i know what it's talking about...

My problem was :

try
{
if (somestr==null)
{
// do something
}
else
{
// do something else
}
}
catch
{
System.Diag.Debug.writeline"blahhh"
}

and it was running the //do something code AND then the // do something else code, THEN running the System.Diag code!!

Crazy stuff!

Thanks for the info, so this is not a debugger bug? so why does it NOT do this in VB.NET?!!

Axum
 
Back
Top