Reply
Has anyone used IL directly?
Old 06-11-2007, 05:27 PM Has anyone used IL directly?
Learning Newbie's Avatar
Moderator

Latest Blog Post:
What Does This Look Like?
Posts: 4,733
Name: John Alexander
I've been given some code and permission to do with it as I like, but everything is done using the ILGenerator class - Reflection - and I don't understand any of it. There are many hundred lines like the example below.

And for anybody who doesn't know the answer but knows some .NET, IL = Intermediate Language, aka MSIL. When you compile a .NET assembly it's turned into IL, which is somewhat like portable assembly language. The JIT (Just In Time) compiler then translates this at runtime into instructions optimized for the local machine, taking into account CPU type and number, and things like that.

I can see it's loading three arguments and then calling a method, and setting a breakpoint this happens so often I just can't pull meaningful info by debugging it. Is there any way I can take this in memory only assembly that gets generated, and decompile it from memory to see what's really going on?

ilGen.Emit(OpCodes.Ldarg_0);
ilGen.Emit(OpCodes.Ldarg_1);
ilGen.Emit(OpCodes.Ldarg_2);
ilGen.Emit(OpCodes.Call,
typeof(InsaneGeneratedClass).GetMethod("DispatchEv ent",
BindingFlags.Instance | BindingFlags.NonPublic));
ilGen.Emit(OpCodes.Ret);
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is online now
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Reply     « Reply to Has anyone used IL directly?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12050 seconds with 13 queries