In a previous post, dotNET - Under the Hood, IL Assembly , I briefly described how to write some IL Code to an Assembly, but what if at a later occasion you'll want to invoke these methods from the dll. This could be achieved by loading the assembly in an AppDomain and then invoking the methods within ???? Or you could use what are known as DynamicMethod s to invoke the methods. DynamicMethod is a class that also resides in the System.Reflection.Emit namespace. Why would you want to use DynamicMethod? it's useful when you want to load methods into memory or write methods in memory and invoke later. We can write IL code in memory in the exact same was as we wrote IL code earlier using the MethodBuilder. In my experience DynamicMethod is a bit tricky to get right especially when you try to invoke your Dynamic method. The problem I found was with the constructor parameters, what do they mean; There are 6 constructor overloads in all; half of these are associated with an class in...
Layman explanations of Software coding and configuration techniques. With example code where possible.