Emitting Dynamic Assemblies

This section describes a set of managed types in the System.Reflection.Emit namespace that allow a compiler or tool to emit metadata and Microsoft intermediate language (MSIL) at run time and optionally generate a portable executable (PE) file on disk. 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.

The following services are provided by reflection emit:

Defines assemblies at run time and then runs and/or saves them to disk.

Defines modules in new assemblies at run time and then runs and/or saves them to disk.

Defines types at run time, creates instances of these types, and invokes the type's methods.

Defines symbolic information for defined modules that can be used by tools such as debuggers and code profilers.

The metadata emit interfaces described in the Metadata API specification (located in the %systemroot%\Microsoft.NET\Framework SDK\Tool Developers Guide\Docs directory) and the Assembly Manifest specification (located in the %systemroot%\Microsoft.NET\Framework SDK\Tool Developers Guide\Docs directory) provide an alternative set of unmanaged APIs for defining metadata. Reflection emit provides stronger semantic error checking and a higher level of abstraction of the metadata than the metadata emit interfaces.