Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug IL code generated at runtime using Reflection.Emit

Tags:

c#

.net

vb.net

I am trying to generate some code at runtime using the DynamicMethod class in the Reflection.Emit namespace but for some reason its throwing a "VerificationException". Here is the IL code I am trying to use...

ldarg.1
ldarg.0
ldfld, System.String FirstName
callvirt, Void Write(System.String)
ldarg.1
ldarg.0
ldfld, System.String LastName
callvirt, Void Write(System.String)
ldarg.1
ldarg.0
ldfld, Int32 Age
callvirt, Void Write(Int32)
ret

I need a way to debug the generated IL code. What options do I have? I am using VS2008 professional.

like image 528
Autodidact Avatar asked Nov 26 '08 15:11

Autodidact


1 Answers

I have found some more help here...

DebuggerVisualizer for DynamicMethod (Show me the IL) It's is a debugger visualizer using which you will be able to see the generated IL at runtime!

And even better is Debugging LCG which allows you to debug the generated code at runtime using Windbg!

like image 148
Autodidact Avatar answered Oct 19 '22 07:10

Autodidact