Viewing IL when debugging

S

Sheila Jones

Hi,

I posted this question in the visual studio newsgroup, but didn't get a
reply. I'm reposting it here, hoping it's not too off-topic:

When debugging a C# program, how do I see the IL code? I can only get the
disassembly window to show the original C# source and the native Intel
assembly code. Thanks!
 
P

Peter Bromberg [C# MVP]

Sheila
Unless I stand corrected, the only way to do this is to use the ILDASM.EXE
utility on the compiled assembly. You can certainly put
this into your Tools menu available from the IDE.
--Peter
 
S

Sheila Jones

Oh. I was hoping to learn a bit about IL by seeing how my C# code had been
translated and stepping through it in the debugger. But it sounds like
that's not possible.

As an alternative, is there a way to generate an output file that includes
C# and IL code? That would be better than nothing.

Thank you for the reply.
 
M

Mattias Sjögren

Sheila,
As an alternative, is there a way to generate an output file that includes
C# and IL code? That would be better than nothing.

Ildasm.exe /source



Mattias
 
S

Sheila Jones

Hello Mattias,

Thank you for your reply, which certainly works. But I now have a couple
more questions:

Is there a way to show the C# source in a different colour, to distinguish
it from the IL?

Also, I have some long C# statements that are split over 2 or more lines.
Ildasm shows the first line of source, then the IL, then the remaining
source line(s), which is confusing. Is there any way to show all the lines
of the statement first, then the corresponding IL?

Thanks once again.
 
M

Mattias Sjögren

Sheila,
Is there a way to show the C# source in a different colour, to distinguish
it from the IL?

The C# source is included as comments in the IL assembler code right?
So any editor that can color the comments differently could do that.
But I don't think VS.NET will do that while debugging since it doesn't
have any IL assembler support.

Is there any way to show all the lines
of the statement first, then the corresponding IL?

Not that I know.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top