.Net Runtime Library for Delphi
Close
Emitting Dynamic Methods and Assemblies

This section describes a set of managed types in the CNClrLib.Core.Intf namespace (In C#, these types will be defined in 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 namespace is referred to as reflection emit.

Reflection emit provides the following capabilities:

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

  • Define assemblies at run time and then run them and/or save them to disk.

  • Define assemblies at run time, run them, and then unload them and allow garbage collection to reclaim their resources.

  • Define modules in new assemblies at run time and then run and/or save them to disk.

  • Define types in modules at run time, create instances of these types, and invoke their methods.

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

Reference

OpCodes

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

Security Issues in Reflection Emit

Describes security issues related to creating dynamic assemblies using reflection emit.

System.Reflection.Emit

Contains managed classes used to emit dynamic methods, assemblies, and types.

Related Sections

Reflection Overview

Explains how to explore metadata and managed code.