Emitting MSIL Through Reflection

The .NET framework provides you with the capability to create code on-the-fly through the System.Reflection.Emit namespace. The code that you create through Emit is MSIL code. Essentially, the functionality in this namespace gives you the ability to dynamically create an assembly and a module within that assembly. You can dynamically define any number of classes and methods within the assembly’s module, and then invoke those methods at runtime (which will automatically be JIT compiled to very efficient machine code). You can even save the assembly to disk for later use.

Note

In addition to having the capability to generate MSIL code through System.Reflection.Emit, the .NET CodeDom technology provided by the

Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.