ModuleBuilder.DefineType ModuleBuilder.DefineType ModuleBuilder.DefineType ModuleBuilder.DefineType Method

Definition

Constructs a TypeBuilder. To define a value type, define a type that derives from ValueType.

Overloads

DefineType(String, TypeAttributes, Type, PackingSize, Int32) DefineType(String, TypeAttributes, Type, PackingSize, Int32) DefineType(String, TypeAttributes, Type, PackingSize, Int32)

Constructs a TypeBuilder given the type name, attributes, the type that the defined type extends, the packing size of the defined type, and the total size of the defined type.

DefineType(String, TypeAttributes, Type, Type[]) DefineType(String, TypeAttributes, Type, Type[]) DefineType(String, TypeAttributes, Type, Type[]) DefineType(String, TypeAttributes, Type, Type[])

Constructs a TypeBuilder given the type name, attributes, the type that the defined type extends, and the interfaces that the defined type implements.

DefineType(String, TypeAttributes, Type, Int32) DefineType(String, TypeAttributes, Type, Int32) DefineType(String, TypeAttributes, Type, Int32) DefineType(String, TypeAttributes, Type, Int32)

Constructs a TypeBuilder given the type name, the attributes, the type that the defined type extends, and the total size of the type.

DefineType(String, TypeAttributes, Type, PackingSize) DefineType(String, TypeAttributes, Type, PackingSize) DefineType(String, TypeAttributes, Type, PackingSize) DefineType(String, TypeAttributes, Type, PackingSize)

Constructs a TypeBuilder given the type name, the attributes, the type that the defined type extends, and the packing size of the type.

DefineType(String, TypeAttributes) DefineType(String, TypeAttributes) DefineType(String, TypeAttributes) DefineType(String, TypeAttributes)

Constructs a TypeBuilder given the type name and the type attributes.

DefineType(String) DefineType(String) DefineType(String) DefineType(String)

Constructs a TypeBuilder for a private type with the specified name in this module.

DefineType(String, TypeAttributes, Type) DefineType(String, TypeAttributes, Type) DefineType(String, TypeAttributes, Type) DefineType(String, TypeAttributes, Type)

Constructs a TypeBuilder given type name, its attributes, and the type that the defined type extends.

DefineType(String, TypeAttributes, Type, PackingSize, Int32) DefineType(String, TypeAttributes, Type, PackingSize, Int32) DefineType(String, TypeAttributes, Type, PackingSize, Int32)

Constructs a TypeBuilder given the type name, attributes, the type that the defined type extends, the packing size of the defined type, and the total size of the defined type.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineType(System::String ^ name, System::Reflection::TypeAttributes attr, Type ^ parent, System::Reflection::Emit::PackingSize packingSize, int typesize);
public System.Reflection.Emit.TypeBuilder DefineType (string name, System.Reflection.TypeAttributes attr, Type parent, System.Reflection.Emit.PackingSize packingSize, int typesize);
member this.DefineType : string * System.Reflection.TypeAttributes * Type * System.Reflection.Emit.PackingSize * int -> System.Reflection.Emit.TypeBuilder

Parameters

name
String String String String

The full path of the type. name cannot contain embedded nulls.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

The attributes of the defined type.

parent
Type Type Type Type

The type that the defined type extends.

packingSize
PackingSize PackingSize PackingSize PackingSize

The packing size of the type.

typesize
Int32 Int32 Int32 Int32

The total size of the type.

Returns

A TypeBuilder created with all of the requested attributes.

Exceptions

A type with the given name exists in the parent assembly of this module.

-or-

Nested type attributes are set on a type that is not nested.

Examples

The following example creates a TypeBuilder in the current dynamic module using CreateType, builds and completes the type, and saves the assembly.

AssemblyName^ asmname = gcnew AssemblyName;
asmname->Name = "assemfilename.exe";
AssemblyBuilder^ asmbuild = System::Threading::Thread::GetDomain()->
   DefineDynamicAssembly( asmname, AssemblyBuilderAccess::RunAndSave );
ModuleBuilder^ modbuild = asmbuild->DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder^ typebuild1 = modbuild->DefineType( "typename" );
typebuild1->CreateType();
asmbuild->Save( "assemfilename.exe" );
AssemblyName asmname = new AssemblyName();
asmname.Name = "assemfilename.exe";        
AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain().
            DefineDynamicAssembly(asmname, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder modbuild = asmbuild.DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder typebuild1 = modbuild.DefineType( "typename" );
typebuild1.CreateType();
asmbuild.Save( "assemfilename.exe" );
Dim asmname As New AssemblyName()
asmname.Name = "assemfilename.exe"
Dim asmbuild As AssemblyBuilder = _
   System.Threading.Thread.GetDomain().DefineDynamicAssembly(asmname, _
   AssemblyBuilderAccess.RunAndSave)
Dim modbuild As ModuleBuilder = _
   asmbuild.DefineDynamicModule("modulename", "assemfilename.exe")
Dim typebuild1 As TypeBuilder = modbuild.DefineType("typename")
typebuild1.CreateType()
asmbuild.Save("assemfilename.exe")

Remarks

Type names must be unique within an assembly. You cannot have two types with the same name in two different modules of an assembly.

Note

Starting with the .NET Framework 2.0 Service Pack 1, this member no longer requires ReflectionPermission with the ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the .NET Framework 3.5 or later.

DefineType(String, TypeAttributes, Type, Type[]) DefineType(String, TypeAttributes, Type, Type[]) DefineType(String, TypeAttributes, Type, Type[]) DefineType(String, TypeAttributes, Type, Type[])

Constructs a TypeBuilder given the type name, attributes, the type that the defined type extends, and the interfaces that the defined type implements.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineType(System::String ^ name, System::Reflection::TypeAttributes attr, Type ^ parent, cli::array <Type ^> ^ interfaces);
[System.Runtime.InteropServices.ComVisible(true)]
public System.Reflection.Emit.TypeBuilder DefineType (string name, System.Reflection.TypeAttributes attr, Type parent, Type[] interfaces);
member this.DefineType : string * System.Reflection.TypeAttributes * Type * Type[] -> System.Reflection.Emit.TypeBuilder
Public Function DefineType (name As String, attr As TypeAttributes, parent As Type, interfaces As Type()) As TypeBuilder

Parameters

name
String String String String

The full path of the type. name cannot contain embedded nulls.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

The attributes to be associated with the type.

parent
Type Type Type Type

The type that the defined type extends.

interfaces
Type[]

The list of interfaces that the type implements.

Returns

A TypeBuilder created with all of the requested attributes.

Exceptions

A type with the given name exists in the parent assembly of this module.

-or-

Nested type attributes are set on a type that is not nested.

Examples

The following example creates a TypeBuilder in the current dynamic module using CreateType, builds and completes the type, and saves the assembly.

AssemblyName^ asmname = gcnew AssemblyName;
asmname->Name = "assemfilename.exe";
AssemblyBuilder^ asmbuild = System::Threading::Thread::GetDomain()->
   DefineDynamicAssembly( asmname, AssemblyBuilderAccess::RunAndSave );
ModuleBuilder^ modbuild = asmbuild->DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder^ typebuild1 = modbuild->DefineType( "typename" );
typebuild1->CreateType();
asmbuild->Save( "assemfilename.exe" );
AssemblyName asmname = new AssemblyName();
asmname.Name = "assemfilename.exe";        
AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain().
            DefineDynamicAssembly(asmname, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder modbuild = asmbuild.DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder typebuild1 = modbuild.DefineType( "typename" );
typebuild1.CreateType();
asmbuild.Save( "assemfilename.exe" );
Dim asmname As New AssemblyName()
asmname.Name = "assemfilename.exe"
Dim asmbuild As AssemblyBuilder = _
   System.Threading.Thread.GetDomain().DefineDynamicAssembly(asmname, _
   AssemblyBuilderAccess.RunAndSave)
Dim modbuild As ModuleBuilder = _
   asmbuild.DefineDynamicModule("modulename", "assemfilename.exe")
Dim typebuild1 As TypeBuilder = modbuild.DefineType("typename")
typebuild1.CreateType()
asmbuild.Save("assemfilename.exe")

Remarks

Type names must be unique within an assembly. You cannot have two types with the same name in two different modules of an assembly.

Note

Starting with the .NET Framework 2.0 Service Pack 1, this member no longer requires ReflectionPermission with the ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the .NET Framework 3.5 or later.

DefineType(String, TypeAttributes, Type, Int32) DefineType(String, TypeAttributes, Type, Int32) DefineType(String, TypeAttributes, Type, Int32) DefineType(String, TypeAttributes, Type, Int32)

Constructs a TypeBuilder given the type name, the attributes, the type that the defined type extends, and the total size of the type.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineType(System::String ^ name, System::Reflection::TypeAttributes attr, Type ^ parent, int typesize);
public System.Reflection.Emit.TypeBuilder DefineType (string name, System.Reflection.TypeAttributes attr, Type parent, int typesize);
member this.DefineType : string * System.Reflection.TypeAttributes * Type * int -> System.Reflection.Emit.TypeBuilder
Public Function DefineType (name As String, attr As TypeAttributes, parent As Type, typesize As Integer) As TypeBuilder

Parameters

name
String String String String

The full path of the type. name cannot contain embedded nulls.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

The attributes of the defined type.

parent
Type Type Type Type

The type that the defined type extends.

typesize
Int32 Int32 Int32 Int32

The total size of the type.

Returns

Exceptions

A type with the given name exists in the parent assembly of this module.

-or-

Nested type attributes are set on a type that is not nested.

Examples

The following example creates a TypeBuilder in the current dynamic module using CreateType, builds and completes the type, and saves the assembly.

AssemblyName^ asmname = gcnew AssemblyName;
asmname->Name = "assemfilename.exe";
AssemblyBuilder^ asmbuild = System::Threading::Thread::GetDomain()->
   DefineDynamicAssembly( asmname, AssemblyBuilderAccess::RunAndSave );
ModuleBuilder^ modbuild = asmbuild->DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder^ typebuild1 = modbuild->DefineType( "typename" );
typebuild1->CreateType();
asmbuild->Save( "assemfilename.exe" );
AssemblyName asmname = new AssemblyName();
asmname.Name = "assemfilename.exe";        
AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain().
            DefineDynamicAssembly(asmname, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder modbuild = asmbuild.DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder typebuild1 = modbuild.DefineType( "typename" );
typebuild1.CreateType();
asmbuild.Save( "assemfilename.exe" );
Dim asmname As New AssemblyName()
asmname.Name = "assemfilename.exe"
Dim asmbuild As AssemblyBuilder = _
   System.Threading.Thread.GetDomain().DefineDynamicAssembly(asmname, _
   AssemblyBuilderAccess.RunAndSave)
Dim modbuild As ModuleBuilder = _
   asmbuild.DefineDynamicModule("modulename", "assemfilename.exe")
Dim typebuild1 As TypeBuilder = modbuild.DefineType("typename")
typebuild1.CreateType()
asmbuild.Save("assemfilename.exe")

Remarks

Type names must be unique within an assembly. It is forbidden to have two types with the same name in two different modules of an assembly.

Note

Starting with the .NET Framework 2.0 Service Pack 1, this member no longer requires ReflectionPermission with the ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the .NET Framework 3.5 or later.

DefineType(String, TypeAttributes, Type, PackingSize) DefineType(String, TypeAttributes, Type, PackingSize) DefineType(String, TypeAttributes, Type, PackingSize) DefineType(String, TypeAttributes, Type, PackingSize)

Constructs a TypeBuilder given the type name, the attributes, the type that the defined type extends, and the packing size of the type.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineType(System::String ^ name, System::Reflection::TypeAttributes attr, Type ^ parent, System::Reflection::Emit::PackingSize packsize);
public System.Reflection.Emit.TypeBuilder DefineType (string name, System.Reflection.TypeAttributes attr, Type parent, System.Reflection.Emit.PackingSize packsize);
member this.DefineType : string * System.Reflection.TypeAttributes * Type * System.Reflection.Emit.PackingSize -> System.Reflection.Emit.TypeBuilder
Public Function DefineType (name As String, attr As TypeAttributes, parent As Type, packsize As PackingSize) As TypeBuilder

Parameters

name
String String String String

The full path of the type. name cannot contain embedded nulls.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

The attributes of the defined type.

parent
Type Type Type Type

The type that the defined type extends.

packsize
PackingSize PackingSize PackingSize PackingSize

The packing size of the type.

Returns

Exceptions

A type with the given name exists in the parent assembly of this module.

-or-

Nested type attributes are set on a type that is not nested.

Examples

The following example creates a TypeBuilder in the current dynamic module using CreateType, builds and completes the type, and saves the assembly.

AssemblyName^ asmname = gcnew AssemblyName;
asmname->Name = "assemfilename.exe";
AssemblyBuilder^ asmbuild = System::Threading::Thread::GetDomain()->
   DefineDynamicAssembly( asmname, AssemblyBuilderAccess::RunAndSave );
ModuleBuilder^ modbuild = asmbuild->DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder^ typebuild1 = modbuild->DefineType( "typename" );
typebuild1->CreateType();
asmbuild->Save( "assemfilename.exe" );
AssemblyName asmname = new AssemblyName();
asmname.Name = "assemfilename.exe";        
AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain().
            DefineDynamicAssembly(asmname, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder modbuild = asmbuild.DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder typebuild1 = modbuild.DefineType( "typename" );
typebuild1.CreateType();
asmbuild.Save( "assemfilename.exe" );
Dim asmname As New AssemblyName()
asmname.Name = "assemfilename.exe"
Dim asmbuild As AssemblyBuilder = _
   System.Threading.Thread.GetDomain().DefineDynamicAssembly(asmname, _
   AssemblyBuilderAccess.RunAndSave)
Dim modbuild As ModuleBuilder = _
   asmbuild.DefineDynamicModule("modulename", "assemfilename.exe")
Dim typebuild1 As TypeBuilder = modbuild.DefineType("typename")
typebuild1.CreateType()
asmbuild.Save("assemfilename.exe")

Remarks

Type names must be unique within an assembly. You cannot have two types with the same name in two different modules of an assembly.

Note

Starting with the .NET Framework 2.0 Service Pack 1, this member no longer requires ReflectionPermission with the ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the .NET Framework 3.5 or later.

DefineType(String, TypeAttributes) DefineType(String, TypeAttributes) DefineType(String, TypeAttributes) DefineType(String, TypeAttributes)

Constructs a TypeBuilder given the type name and the type attributes.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineType(System::String ^ name, System::Reflection::TypeAttributes attr);
public System.Reflection.Emit.TypeBuilder DefineType (string name, System.Reflection.TypeAttributes attr);
member this.DefineType : string * System.Reflection.TypeAttributes -> System.Reflection.Emit.TypeBuilder
Public Function DefineType (name As String, attr As TypeAttributes) As TypeBuilder

Parameters

name
String String String String

The full path of the type. name cannot contain embedded nulls.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

The attributes of the defined type.

Returns

A TypeBuilder created with all of the requested attributes.

Exceptions

A type with the given name exists in the parent assembly of this module.

-or-

Nested type attributes are set on a type that is not nested.

Examples

The following example creates a TypeBuilder in the current dynamic module using CreateType, builds and completes the type, and saves the assembly.

AssemblyName^ asmname = gcnew AssemblyName;
asmname->Name = "assemfilename.exe";
AssemblyBuilder^ asmbuild = System::Threading::Thread::GetDomain()->
   DefineDynamicAssembly( asmname, AssemblyBuilderAccess::RunAndSave );
ModuleBuilder^ modbuild = asmbuild->DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder^ typebuild1 = modbuild->DefineType( "typename" );
typebuild1->CreateType();
asmbuild->Save( "assemfilename.exe" );
AssemblyName asmname = new AssemblyName();
asmname.Name = "assemfilename.exe";        
AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain().
            DefineDynamicAssembly(asmname, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder modbuild = asmbuild.DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder typebuild1 = modbuild.DefineType( "typename" );
typebuild1.CreateType();
asmbuild.Save( "assemfilename.exe" );
Dim asmname As New AssemblyName()
asmname.Name = "assemfilename.exe"
Dim asmbuild As AssemblyBuilder = _
   System.Threading.Thread.GetDomain().DefineDynamicAssembly(asmname, _
   AssemblyBuilderAccess.RunAndSave)
Dim modbuild As ModuleBuilder = _
   asmbuild.DefineDynamicModule("modulename", "assemfilename.exe")
Dim typebuild1 As TypeBuilder = modbuild.DefineType("typename")
typebuild1.CreateType()
asmbuild.Save("assemfilename.exe")

Remarks

Type names must be unique within an assembly. You cannot have two types with the same name in two different modules of an assembly.

Note

Starting with the .NET Framework 2.0 Service Pack 1, this member no longer requires ReflectionPermission with the ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the .NET Framework 3.5 or later.

DefineType(String) DefineType(String) DefineType(String) DefineType(String)

Constructs a TypeBuilder for a private type with the specified name in this module.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineType(System::String ^ name);
public System.Reflection.Emit.TypeBuilder DefineType (string name);
member this.DefineType : string -> System.Reflection.Emit.TypeBuilder
Public Function DefineType (name As String) As TypeBuilder

Parameters

name
String String String String

The full path of the type, including the namespace. name cannot contain embedded nulls.

Returns

A private type with the specified name.

Exceptions

A type with the given name exists in the parent assembly of this module.

-or-

Nested type attributes are set on a type that is not nested.

Examples

The following example creates a TypeBuilder in the current dynamic module using CreateType, builds and completes the type, and saves the assembly.

AssemblyName^ asmname = gcnew AssemblyName;
asmname->Name = "assemfilename.exe";
AssemblyBuilder^ asmbuild = System::Threading::Thread::GetDomain()->
   DefineDynamicAssembly( asmname, AssemblyBuilderAccess::RunAndSave );
ModuleBuilder^ modbuild = asmbuild->DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder^ typebuild1 = modbuild->DefineType( "typename" );
typebuild1->CreateType();
asmbuild->Save( "assemfilename.exe" );
AssemblyName asmname = new AssemblyName();
asmname.Name = "assemfilename.exe";        
AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain().
            DefineDynamicAssembly(asmname, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder modbuild = asmbuild.DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder typebuild1 = modbuild.DefineType( "typename" );
typebuild1.CreateType();
asmbuild.Save( "assemfilename.exe" );
Dim asmname As New AssemblyName()
asmname.Name = "assemfilename.exe"
Dim asmbuild As AssemblyBuilder = _
   System.Threading.Thread.GetDomain().DefineDynamicAssembly(asmname, _
   AssemblyBuilderAccess.RunAndSave)
Dim modbuild As ModuleBuilder = _
   asmbuild.DefineDynamicModule("modulename", "assemfilename.exe")
Dim typebuild1 As TypeBuilder = modbuild.DefineType("typename")
typebuild1.CreateType()
asmbuild.Save("assemfilename.exe")

Remarks

Type names must be unique within an assembly. You cannot have two types with the same name in two different modules of an assembly.

Note

Starting with the .NET Framework 2.0 Service Pack 1, this member no longer requires ReflectionPermission with the ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the .NET Framework 3.5 or later.

DefineType(String, TypeAttributes, Type) DefineType(String, TypeAttributes, Type) DefineType(String, TypeAttributes, Type) DefineType(String, TypeAttributes, Type)

Constructs a TypeBuilder given type name, its attributes, and the type that the defined type extends.

public:
 System::Reflection::Emit::TypeBuilder ^ DefineType(System::String ^ name, System::Reflection::TypeAttributes attr, Type ^ parent);
public System.Reflection.Emit.TypeBuilder DefineType (string name, System.Reflection.TypeAttributes attr, Type parent);
member this.DefineType : string * System.Reflection.TypeAttributes * Type -> System.Reflection.Emit.TypeBuilder
Public Function DefineType (name As String, attr As TypeAttributes, parent As Type) As TypeBuilder

Parameters

name
String String String String

The full path of the type. name cannot contain embedded nulls.

attr
TypeAttributes TypeAttributes TypeAttributes TypeAttributes

The attribute to be associated with the type.

parent
Type Type Type Type

The type that the defined type extends.

Returns

A TypeBuilder created with all of the requested attributes.

Exceptions

A type with the given name exists in the parent assembly of this module.

-or-

Nested type attributes are set on a type that is not nested.

Examples

The following example creates a TypeBuilder in the current dynamic module using CreateType, builds and completes the type, and saves the assembly.

AssemblyName^ asmname = gcnew AssemblyName;
asmname->Name = "assemfilename.exe";
AssemblyBuilder^ asmbuild = System::Threading::Thread::GetDomain()->
   DefineDynamicAssembly( asmname, AssemblyBuilderAccess::RunAndSave );
ModuleBuilder^ modbuild = asmbuild->DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder^ typebuild1 = modbuild->DefineType( "typename" );
typebuild1->CreateType();
asmbuild->Save( "assemfilename.exe" );
AssemblyName asmname = new AssemblyName();
asmname.Name = "assemfilename.exe";        
AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain().
            DefineDynamicAssembly(asmname, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder modbuild = asmbuild.DefineDynamicModule( "modulename",
   "assemfilename.exe" );
TypeBuilder typebuild1 = modbuild.DefineType( "typename" );
typebuild1.CreateType();
asmbuild.Save( "assemfilename.exe" );
Dim asmname As New AssemblyName()
asmname.Name = "assemfilename.exe"
Dim asmbuild As AssemblyBuilder = _
   System.Threading.Thread.GetDomain().DefineDynamicAssembly(asmname, _
   AssemblyBuilderAccess.RunAndSave)
Dim modbuild As ModuleBuilder = _
   asmbuild.DefineDynamicModule("modulename", "assemfilename.exe")
Dim typebuild1 As TypeBuilder = modbuild.DefineType("typename")
typebuild1.CreateType()
asmbuild.Save("assemfilename.exe")

Remarks

Type names must be unique within an assembly. You cannot have two types with the same name in two different modules of an assembly.

Note

Starting with the .NET Framework 2.0 Service Pack 1, this member no longer requires ReflectionPermission with the ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the .NET Framework 3.5 or later.

Applies to