Export (0) Print
Expand All

AssemblyBuilder Class

Defines and represents a dynamic assembly.

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

[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType.None)] 
public sealed class AssemblyBuilder : Assembly, _AssemblyBuilder
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.None) */ 
public final class AssemblyBuilder extends Assembly implements _AssemblyBuilder
ComVisibleAttribute(true) 
ClassInterfaceAttribute(ClassInterfaceType.None) 
public final class AssemblyBuilder extends Assembly implements _AssemblyBuilder
Not applicable.

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 Save method. To generate an executable, the SetEntryPoint method must be called to identify the method that is the entry point to the assembly. Assemblies are saved as DLL by default, unless SetEntryPoint 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 DefineDynamicModule.

Some methods on the base class 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 Assembly object.

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

To get an AssemblyBuilder object, use the System.AppDomain.DefineDynamicAssembly method.

The following code example shows how to define a dynamic assembly with one module. The module in the example assembly contains one type, MyDynamicType, which has a private field, a property that gets and sets the private field, constructors that initialize the private field, and a method that multiplies a user-supplied number by the private field value and returns the result.

AssemblyBuilderAccess.RunAndSave is specified when the assembly is created. The assembly code is used immediately, and the assembly is also saved to disk so that it can be examined with MSIL Disassembler (Ildasm.exe) or used in another program.

System.Object
   System.Reflection.Assembly
    System.Reflection.Emit.AssemblyBuilder

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft