Dev @ Work

A day in the life of a developer

Baking IL With DynamicMethod

May 31st, 2009 by

At the moment I am building a new script engine which is consists of text and expressions embedded in them. Those expressions are basically calls to functions and have any number of arguments. The implementation of those functions is done in C#.

At compile time I don’t know which methods are going to be called so I have to invoke them at runtime. The most obvious way to do that is to use the reflection API of .NET to do a late bound method call. Although, IMHO, this is a perfectly valid solution to this problem it isn’t exactly fast.

System.Reflection.Emit.DynamicMethod is a better alternative for late bound method invocation when it comes to performance. Although it requires you to write Intermediate Language (IL) it is actually quite easy to use.

Read the rest of this entry »

Microsoft Intermediate Language

May 23rd, 2007 by

In deze post zal ik vertellen over Microsoft intermediate language: de assembly taal van het .NET platform, wat je er mee kunt, waarom je het zou gebruiken en hoe je het gebruikt. Read the rest of this entry »