views:

44

answers:

2

I'm trying to debug an assembly that has been compiled in Release mode, so all the "good stuff" like local variables are Optimized away.

As a second approach, I would like to see the IL and the .net Stack, but I don't seem to have that option in Visual Studio 2010 - I only have Disassembly, Registers and Memory View, which is one level lower.

Is there a way to Debug IL in VS2010?

This is .net 3.5SP1 if that matters.

+3  A: 

This is fundamental about .NET, you never execute IL. The JIT compiler translates it to machine code, the two have very little in common. You cannot see IL executing, only machine code.

Yes, all you got to have some idea what the local variable value are is the Disassembly window and the Registers window. The latter shows you what their value is when they get loaded in a CPU register. Some knowledge of x86 (or x64) assembly is required to see the correspondence between the C# and the assembly code to know what register contains what local variable. You'd have to use a Memory window to look at the stack but that's quite impractical, you need to know the value of the ebp register and the offset.

Hans Passant
Thanks for the hint with the ebp. Not as "nice" as I would like it, but I guess that's all I have.
Michael Stum
A: 

You case use tools such as Ildasm and reflector to see the IL and decompile it.

vc 74
The problem is that this doesn't allow step-through-debugging and that the JITter optimized the code which means that the executed code and the source code aren't the same anymore.
Michael Stum
Yes, these are not live debugging tools. Glad to see you found an answer.
vc 74