Szerkesztés

Megosztás a következőn keresztül:


ModuleBuilder.DefineType Method

Definition

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

Overloads

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, 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, 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)

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

DefineType(String, TypeAttributes, Type)

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

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)

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

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

Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs

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);
public System.Reflection.Emit.TypeBuilder DefineType (string name, System.Reflection.TypeAttributes attr, Type? parent, Type[]? interfaces);
public System.Reflection.Emit.TypeBuilder DefineType (string name, System.Reflection.TypeAttributes attr, Type parent, 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
[<System.Runtime.InteropServices.ComVisible(true)>]
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

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

attr
TypeAttributes

The attributes to be associated with the type.

parent
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.

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.

name is null.

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

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

Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs

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);
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
Public Function DefineType (name As String, attr As TypeAttributes, parent As Type, packingSize As PackingSize, typesize As Integer) As TypeBuilder

Parameters

name
String

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

attr
TypeAttributes

The attributes of the defined type.

parent
Type

The type that the defined type extends.

packingSize
PackingSize

The packing size of the type.

typesize
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.

name is null.

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

DefineType(String, TypeAttributes, Type, PackingSize)

Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs

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);
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

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

attr
TypeAttributes

The attributes of the defined type.

parent
Type

The type that the defined type extends.

packsize
PackingSize

The packing size of the type.

Returns

A TypeBuilder object.

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.

name is null.

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

DefineType(String, TypeAttributes)

Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs

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

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

attr
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.

name is null.

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

DefineType(String, TypeAttributes, Type)

Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs

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);
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

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

attr
TypeAttributes

The attribute to be associated with the type.

parent
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.

name is null.

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

DefineType(String, TypeAttributes, Type, Int32)

Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs

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);
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

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

attr
TypeAttributes

The attributes of the defined type.

parent
Type

The type that the defined type extends.

typesize
Int32

The total size of the type.

Returns

A TypeBuilder object.

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.

name is null.

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.

Applies to

DefineType(String)

Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs
Source:
ModuleBuilder.cs

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

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.

name is null.

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