Debugging IL code in VS 2005

Debugging IL code in VS 2005

Post by Tm90cmUgUG » Sat, 20 May 2006 01:44:02


Hello,

I have an assembly that was generated based on some IL code with a matching
PDB. I can set breakpoints in the IL using the VS 2005 de *** , and they
are hit as expected. However, when I try to clear the breakpoints, they are
still observed by the de *** ! This is despite the fact that they are
visually no longer present in the list of breakpoints. Is this a VS bug? Is
there a workaround? Please see the post at
http://www.yqcomputer.com/ +3rd+party+assemblies&rnum=1&hl=en#1863d2f57f0a24c7
for further details on my scenario, if that helps.

Thanks,
Notre
 
 
 

Debugging IL code in VS 2005

Post by jeta » Sat, 20 May 2006 12:25:00

Hi Notre,

Thanks for your post!

Is it possible for you to post some detailed steps to help us reproduce out
your problem? This will be helpful to the understanding.

Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
 
 

Debugging IL code in VS 2005

Post by Tm90cmUgUG » Sun, 21 May 2006 01:39:02

Hi Jeffrey,

What I have done is the to follow the instructions at
http://www.yqcomputer.com/
assembly with debug symbols. More precisely I did the following:

Imagine the assembly I want to debug is called ThirdParty.dll, and it is in
the GAC.
1. I generated an IL file from the assembly by using the following command:
ILDASM /OUT=ThirdParty.il /NOBAR /LINENUM /SOURCE ThirdParty.dll

2. I compiled the IL back into an assembly, this time generating a matching
PDB:

ILASM /DEBUG /DLL /QUIET /OUTPUT=ThirdParty.dll ThirdParty.il

3. Next, I used the strong name utility to register my rebuilt assemly,
skipping verification:

sn -Vr ThirdParty.dll

4. Finally, I installed the assembly into the GAC:

gacutil /i ThirdParty.dll /f

Now the assembly in the GAC is my assembly, rather than the original
author's assembly. I do the following to debug the assembly:

1. Start the process to debug (which loads the rebuilt assembly).
2. Start VS 2005
3. Have VS attach to the process to debug, using managed debugging.
4. Ensure symbols are loaded for the assembly to debug.
5. Open the ThirdParty.il in the VS IDE. Set a breakpoint on an IL
statement, just like I would in, say, a C# file.

Now my breakpoint in the IL is hit. I then try to clear the breakpoint in
the IDE, and it appears visually gone, but when the program executes the IL
statement, it still breaks into the de *** .

Notre
 
 
 

Debugging IL code in VS 2005

Post by jeta » Tue, 23 May 2006 16:03:19

Hi Notre,

Thanks for your detailed steps!

I have tried your listed steps, and I can verify the GAC dll has got the
symbol loaded with "Module" window in VS2005, but when I call certain
method in the dll, the breakpoint in the IL code does not hit at all. I
will give a little more checking to see if I missed anything.

I have some questions regarding your issue:
1. have you tried this way to debug any assembly that is not strange named?
2. does this problem exist in VS.net2003?
3. have you tried this on some other machines with VS2005 installed? Can it
always be reproduced?

Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
 
 

Debugging IL code in VS 2005

Post by Tm90cmUgUG » Thu, 25 May 2006 01:14:02

Hi Jeffrey,

In response to your 3 questions:

1. no
2. no
3. no

Notre
 
 
 

Debugging IL code in VS 2005

Post by Tm90cmUgUG » Thu, 25 May 2006 08:01:02

The other problem you may be running into is related to System File
Protection. Your assembly may be getting replaced, depending on if it is
monitored by System File Protection. However, since you say the symbols are
loaded, that shouldn't be the problem...
 
 
 

Debugging IL code in VS 2005

Post by jeta » Thu, 25 May 2006 19:04:12

Hi notre,

Sorry for letting you wait.

I do not think it is caused by system file protection. Because I did not
try to rewrite the system assembly, but I rewrite a very simple assembly
myself and then deploy it in the GAC.

I suggest you try this way on non strong named assembly, this will get rid
of GAC dependency and easier to troubleshoot and reproduce. If you can
reproduce this with non strong named assembly, please feel free to send a
reproduce project to me, I will give it a try.

Currently, I still do not have time to give your steps an another try, but
I promise I will try it as soon as I have time. Thanks for your
understanding.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
 
 

Debugging IL code in VS 2005

Post by jeta » Sat, 27 May 2006 14:58:25

Hi notre,

Sorry for letting you wait.

I have given your steps an another try, and I finally got my test project
break in the IL file breakpoint in VS2005. I can step through the IL code
without any problem, but after I re-click the breakpoint to clear it, I
will not break again at the original breakpoint. It seems everything works
well on my side.

So I recommended you give a test on some other machines to see if this
issue can be reproduce out. I suspect this your machine-specific or
project-specific issue.Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.