System.Reflection.Emit.AssemblyBuilder Class

Defines and represents a dynamic assembly.

See Also: AssemblyBuilder Members


public sealed class AssemblyBuilder : System.Reflection.Assembly, System.Runtime.InteropServices._AssemblyBuilder


A dynamic assembly is an assembly that is created using the Reflection Emit APIs. The dynamic modules in the assembly are saved when the dynamic assembly is saved using the AssemblyBuilder.Save(string) method. To generate an executable, the AssemblyBuilder.SetEntryPoint(System.Reflection.MethodInfo) method must be called to identify the method that is the entry point to the assembly. Assemblies are saved as DLL by default, unless AssemblyBuilder.SetEntryPoint(System.Reflection.MethodInfo) requests the generation of a console application or a Windows-based application.

If a dynamic assembly contains more than one dynamic module, the assembly's manifest file name should match the module's name that is specified as the first argument to AssemblyBuilder.DefineDynamicModule(string).

Some methods on the base class System.Reflection.Assembly such as GetModules and GetLoadedModules will not work correctly when called AssemblyBuilder objects. You can load the defined dynamic assembly and call the methods on the loaded assembly. For example, to ensure that resource modules are included in the returned module list, call GetModules on the loaded System.Reflection.Assembly object.

The signing of a dynamic assembly using System.Reflection.AssemblyName.KeyPair is not effective until the assembly is saved to disk. So, strong names will not work with transient dynamic assemblies.

To get an System.Reflection.Emit.AssemblyBuilder object, use the erload:System.AppDomain.DefineDynamicAssembly method.


Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0,,