Emitting Dynamic Methods and Assemblies

This section describes a set of managed types in the System.Reflection.Emit namespace that enable your application to emit metadata and Microsoft intermediate language (MSIL) at run time. Script engines and compilers are the primary users of this namespace. In this section, the functionality provided by the System.Reflection.Emit namespace is referred to as reflection emit.

Reflection emit provides the following capabilities:

  • Defines lightweight global methods at run time, using the DynamicMethod class, and executes them using delegates.

  • Generates assemblies at run time.

  • Defines types in modules at run time, creates instances of these types, and invokes their methods.

A useful resource for working with metadata and MSIL is the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics" and "Partition III: CIL Instruction Set". The documentation is available online at the ECMA C# and Common Language Infrastructure Standards page on MSDN and on the Ecma International Web site.

In This Section


  • OpCodes
    Catalogs the MSIL instruction codes you can use to build method bodies.

  • System.Reflection.Emit
    Contains managed classes used to emit dynamic methods, assemblies, and types.

  • Type
    Describes the class that represents types in reflection, and that is the base class of TypeBuilder, which represents dynamic types in reflection emit. This class is key to the use of these technologies.

  • System.Reflection
    Contains managed classes used to explore metadata and managed code.