AssemblyBuilder

System.Reflection

Overview

Represents an assembly that is being defined at runtime and can be saved to disk.

The AssemblyBuilder class is used to dynamically generate and save assemblies. It provides methods to define types, methods, fields, and other members within the assembly. This is particularly useful for scenarios like Just-In-Time (JIT) compilation, code generation, and dynamic proxies.

Remarks

An AssemblyBuilder is created by calling the DefineDynamicAssembly method on an AssemblyBuilderAccess object. You can then use the ModuleBuilder obtained from the AssemblyBuilder to define types. The types can then be defined and populated with members such as methods, fields, and properties.

After defining the assembly content, you can save the assembly to a file using the Save method.

Constructors

Methods

Requirements

Namespace: System.Reflection.Emit

Assembly: System.Private.CoreLib (in .NET Core, .NET 5+)

Assembly: System.Reflection.Emit (in .NET Framework)