Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.

Reflection Emit Abstractions

Lists and describes the reflection emit classes you can use to define assemblies and types, methods and method parameters, events, constructors, properties, and so forth.

Reflection Emit Dynamic Method Scenarios

Describes scenarios for emitting and using lightweight dynamic methods.

Reflection Emit Dynamic Assembly Scenarios

Describes scenarios for emitting and using dynamic assemblies.

Security Issues in Reflection Emit

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

How to: Define and Execute Dynamic Methods

Explains how to define a lightweight dynamic method, add MSIL, and execute the completed method without the overhead of defining a dynamic assembly.

How to: Define a Generic Type with Reflection Emit

Shows how to define a generic type in a dynamic module, how to define its generic type parameters, and how to use them in method signatures.

How to: Define a Generic Method with Reflection Emit

Shows how to define a generic method in a dynamic module, how to define its generic type parameters, and how to execute the method.

Defining a Dynamic Assembly

Explains how to create dynamic assemblies, modules, and types; how to add members to types; how to emit MSIL for methods and constructors; and how to add program logic and exception handling.

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.

Reflection

Explains how to explore metadata and managed code.

Types, Properties, Methods, and Events

Provides an overview of the common language runtime and core topics for Silverlight developers.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.