ModuleBuilder ModuleBuilder ModuleBuilder ModuleBuilder Class

定义

定义和表示动态程序集中的模块。Defines and represents a module in a dynamic assembly.

public ref class ModuleBuilder : System::Reflection::Module, System::Runtime::InteropServices::_ModuleBuilder
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public class ModuleBuilder : System.Reflection.Module, System.Runtime.InteropServices._ModuleBuilder
type ModuleBuilder = class
    inherit Module
    interface _ModuleBuilder
Public Class ModuleBuilder
Inherits Module
Implements _ModuleBuilder
继承
ModuleBuilderModuleBuilderModuleBuilderModuleBuilder
属性
实现

示例

下面的代码示例演示ModuleBuilder如何使用创建动态模块。The following code sample demonstrates the use of ModuleBuilder to create a dynamic module. 请注意,ModuleBuilder 是通过在中DefineDynamicModule AssemblyBuilder调用而不是通过构造函数创建的。Note that the ModuleBuilder is created by calling DefineDynamicModule in AssemblyBuilder, rather than through a constructor.

using namespace System;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
public ref class CodeGenerator
{
private:
   AssemblyBuilder^ myAssemblyBuilder;

public:
   CodeGenerator()
   {
      // Get the current application domain for the current thread.
      AppDomain^ myCurrentDomain = AppDomain::CurrentDomain;
      AssemblyName^ myAssemblyName = gcnew AssemblyName;
      myAssemblyName->Name = "TempAssembly";

      // Define a dynamic assembly in the current application domain.
      myAssemblyBuilder = myCurrentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run );

      // Define a dynamic module in this assembly.
      ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule" );

      // Define a runtime class with specified name and attributes.
      TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "TempClass", TypeAttributes::Public );

      // Add 'Greeting' field to the class, with the specified attribute and type.
      FieldBuilder^ greetingField = myTypeBuilder->DefineField( "Greeting", String::typeid, FieldAttributes::Public );
      array<Type^>^myMethodArgs = {String::typeid};

      // Add 'MyMethod' method to the class, with the specified attribute and signature.
      MethodBuilder^ myMethod = myTypeBuilder->DefineMethod( "MyMethod", MethodAttributes::Public, CallingConventions::Standard, nullptr, myMethodArgs );
      ILGenerator^ methodIL = myMethod->GetILGenerator();
      methodIL->EmitWriteLine( "In the method..." );
      methodIL->Emit( OpCodes::Ldarg_0 );
      methodIL->Emit( OpCodes::Ldarg_1 );
      methodIL->Emit( OpCodes::Stfld, greetingField );
      methodIL->Emit( OpCodes::Ret );
      myTypeBuilder->CreateType();
   }

   property AssemblyBuilder^ MyAssembly 
   {
      AssemblyBuilder^ get()
      {
         return this->myAssemblyBuilder;
      }
   }
};

int main()
{
   CodeGenerator^ myCodeGenerator = gcnew CodeGenerator;

   // Get the assembly builder for 'myCodeGenerator' object.
   AssemblyBuilder^ myAssemblyBuilder = myCodeGenerator->MyAssembly;

   // Get the module builder for the above assembly builder object .
   ModuleBuilder^ myModuleBuilder = myAssemblyBuilder->GetDynamicModule( "TempModule" );
   Console::WriteLine( "The fully qualified name and path to this module is :{0}", myModuleBuilder->FullyQualifiedName );
   Type^ myType = myModuleBuilder->GetType( "TempClass" );
   MethodInfo^ myMethodInfo = myType->GetMethod( "MyMethod" );

   // Get the token used to identify the method within this module.
   MethodToken myMethodToken = myModuleBuilder->GetMethodToken( myMethodInfo );
   Console::WriteLine( "Token used to identify the method of 'myType'"
   " within the module is {0:x}", myMethodToken.Token );
   array<Object^>^args = {"Hello."};
   Object^ myObject = Activator::CreateInstance( myType, nullptr, nullptr );
   myMethodInfo->Invoke( myObject, args );
}
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Security.Permissions;

public class CodeGenerator
{
   AssemblyBuilder myAssemblyBuilder;
   public CodeGenerator()
   {
      // Get the current application domain for the current thread.
      AppDomain myCurrentDomain = AppDomain.CurrentDomain;
      AssemblyName myAssemblyName = new AssemblyName();
      myAssemblyName.Name = "TempAssembly";

      // Define a dynamic assembly in the current application domain.
      myAssemblyBuilder = myCurrentDomain.DefineDynamicAssembly
                     (myAssemblyName, AssemblyBuilderAccess.Run);

      // Define a dynamic module in this assembly.
      ModuleBuilder myModuleBuilder = myAssemblyBuilder.
                                      DefineDynamicModule("TempModule");

      // Define a runtime class with specified name and attributes.
      TypeBuilder myTypeBuilder = myModuleBuilder.DefineType
                                       ("TempClass",TypeAttributes.Public);

      // Add 'Greeting' field to the class, with the specified attribute and type.
      FieldBuilder greetingField = myTypeBuilder.DefineField("Greeting", 
                                                            typeof(String), FieldAttributes.Public);
      Type[] myMethodArgs = { typeof(String) };

      // Add 'MyMethod' method to the class, with the specified attribute and signature.
      MethodBuilder myMethod = myTypeBuilder.DefineMethod("MyMethod",
         MethodAttributes.Public, CallingConventions.Standard, null,myMethodArgs);

      ILGenerator methodIL = myMethod.GetILGenerator();
      methodIL.EmitWriteLine("In the method...");
      methodIL.Emit(OpCodes.Ldarg_0);
      methodIL.Emit(OpCodes.Ldarg_1);
      methodIL.Emit(OpCodes.Stfld, greetingField);
      methodIL.Emit(OpCodes.Ret);
      myTypeBuilder.CreateType();
   }
   public AssemblyBuilder MyAssembly
   {
      get
      {
         return this.myAssemblyBuilder;
      }
   }
}
public class TestClass
{
   [PermissionSetAttribute(SecurityAction.Demand, Name="FullTrust")]
   public static void Main()
   {
      CodeGenerator myCodeGenerator = new CodeGenerator();
      // Get the assembly builder for 'myCodeGenerator' object.
      AssemblyBuilder myAssemblyBuilder = myCodeGenerator.MyAssembly;
      // Get the module builder for the above assembly builder object .
      ModuleBuilder myModuleBuilder = myAssemblyBuilder.
                                                           GetDynamicModule("TempModule");
      Console.WriteLine("The fully qualified name and path to this "
                               + "module is :" +myModuleBuilder.FullyQualifiedName);
      Type myType = myModuleBuilder.GetType("TempClass");
      MethodInfo myMethodInfo = 
                                                myType.GetMethod("MyMethod");
       // Get the token used to identify the method within this module.
      MethodToken myMethodToken = 
                        myModuleBuilder.GetMethodToken(myMethodInfo);
      Console.WriteLine("Token used to identify the method of 'myType'"
                    + " within the module is {0:x}",myMethodToken.Token);
     object[] args={"Hello."};
     object myObject = Activator.CreateInstance(myType,null,null);
     myMethodInfo.Invoke(myObject,args);
   }
}
Imports System.Reflection
Imports System.Reflection.Emit
Imports System.Security.Permissions

Public Class CodeGenerator
   Private myAssemblyBuilder As AssemblyBuilder

   Public Sub New()
      ' Get the current application domain for the current thread.
      Dim myCurrentDomain As AppDomain = AppDomain.CurrentDomain
      Dim myAssemblyName As New AssemblyName()
      myAssemblyName.Name = "TempAssembly"

      ' Define a dynamic assembly in the current application domain.
      myAssemblyBuilder = _
               myCurrentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.Run)

      ' Define a dynamic module in this assembly.
      Dim myModuleBuilder As ModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule")

      ' Define a runtime class with specified name and attributes.
      Dim myTypeBuilder As TypeBuilder = _
               myModuleBuilder.DefineType("TempClass", TypeAttributes.Public)

      ' Add 'Greeting' field to the class, with the specified attribute and type.
      Dim greetingField As FieldBuilder = _
               myTypeBuilder.DefineField("Greeting", GetType(String), FieldAttributes.Public)
      Dim myMethodArgs As Type() = {GetType(String)}

      ' Add 'MyMethod' method to the class, with the specified attribute and signature.
      Dim myMethod As MethodBuilder = _
               myTypeBuilder.DefineMethod("MyMethod", MethodAttributes.Public, _
               CallingConventions.Standard, Nothing, myMethodArgs)

      Dim methodIL As ILGenerator = myMethod.GetILGenerator()
      methodIL.EmitWriteLine("In the method...")
      methodIL.Emit(OpCodes.Ldarg_0)
      methodIL.Emit(OpCodes.Ldarg_1)
      methodIL.Emit(OpCodes.Stfld, greetingField)
      methodIL.Emit(OpCodes.Ret)
      myTypeBuilder.CreateType()
   End Sub

   Public ReadOnly Property MyAssembly() As AssemblyBuilder
      Get
         Return Me.myAssemblyBuilder
      End Get
   End Property
End Class 'CodeGenerator

Public Class TestClass
   <PermissionSetAttribute(SecurityAction.Demand, Name:="FullTrust")> _
   Public Shared Sub Main()
      Dim myCodeGenerator As New CodeGenerator()
      ' Get the assembly builder for 'myCodeGenerator' object.
      Dim myAssemblyBuilder As AssemblyBuilder = myCodeGenerator.MyAssembly
      ' Get the module builder for the above assembly builder object .
      Dim myModuleBuilder As ModuleBuilder = myAssemblyBuilder.GetDynamicModule("TempModule")
      Console.WriteLine("The fully qualified name and path to this " + _
                        "module is :" + myModuleBuilder.FullyQualifiedName)
      Dim myType As Type = myModuleBuilder.GetType("TempClass")
      Dim myMethodInfo As MethodInfo = myType.GetMethod("MyMethod")
      ' Get the token used to identify the method within this module.
      Dim myMethodToken As MethodToken = myModuleBuilder.GetMethodToken(myMethodInfo)
      Console.WriteLine("Token used to identify the method of 'myType'" + _
                        " within the module is {0:x}", myMethodToken.Token)
      Dim args As Object() = {"Hello."}
      Dim myObject As Object = Activator.CreateInstance(myType, Nothing, Nothing)
      myMethodInfo.Invoke(myObject, args)
   End Sub
End Class 'TestClass

注解

若要获取的ModuleBuilder实例,请AssemblyBuilder.DefineDynamicModule使用方法。To get an instance of ModuleBuilder, use the AssemblyBuilder.DefineDynamicModule method.

构造函数

ModuleBuilder() ModuleBuilder() ModuleBuilder() ModuleBuilder()

属性

Assembly Assembly Assembly Assembly

获取定义此 ModuleBuilder 实例的动态程序集。Gets the dynamic assembly that defined this instance of ModuleBuilder.

CustomAttributes CustomAttributes CustomAttributes CustomAttributes

获取包含此模型自定义属性的集合。Gets a collection that contains this module's custom attributes.

(Inherited from Module)
FullyQualifiedName FullyQualifiedName FullyQualifiedName FullyQualifiedName

获取表示此模块的完全限定名和路径的 StringGets a String representing the fully qualified name and path to this module.

MDStreamVersion MDStreamVersion MDStreamVersion MDStreamVersion

获取元数据流版本。Gets the metadata stream version.

MetadataToken MetadataToken MetadataToken MetadataToken

获取一个标记,该标记用于标识元数据中的当前动态模块。Gets a token that identifies the current dynamic module in metadata.

ModuleHandle ModuleHandle ModuleHandle ModuleHandle

获取模块的图柄。Gets a handle for the module.

(Inherited from Module)
ModuleVersionId ModuleVersionId ModuleVersionId ModuleVersionId

获取可用于区分模块的两个版本的全局唯一标识符 (UUID)。Gets a universally unique identifier (UUID) that can be used to distinguish between two versions of a module.

Name Name Name Name

一个字符串,指示这是内存中的模块。A string that indicates that this is an in-memory module.

ScopeName ScopeName ScopeName ScopeName

获取表示动态模块的名称的字符串。Gets a string that represents the name of the dynamic module.

方法

CreateGlobalFunctions() CreateGlobalFunctions() CreateGlobalFunctions() CreateGlobalFunctions()

完成此动态模块的全局函数定义和全局数据定义。Completes the global function definitions and global data definitions for this dynamic module.

DefineDocument(String, Guid, Guid, Guid) DefineDocument(String, Guid, Guid, Guid) DefineDocument(String, Guid, Guid, Guid) DefineDocument(String, Guid, Guid, Guid)

定义源的文档。Defines a document for source.

DefineEnum(String, TypeAttributes, Type) DefineEnum(String, TypeAttributes, Type) DefineEnum(String, TypeAttributes, Type) DefineEnum(String, TypeAttributes, Type)

用指定类型的单个非静态字段(称为 value__)定义属于值类型的枚举类型。Defines an enumeration type that is a value type with a single non-static field called value__ of the specified type.

DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[]) DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[]) DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[]) DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[])

定义一个具有指定名称、属性、调用约定、返回类型和参数类型的全局方法。Defines a global method with the specified name, attributes, calling convention, return type, and parameter types.

DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type[], Type[], Type[][], Type[][]) DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type[], Type[], Type[][], Type[][]) DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type[], Type[], Type[][], Type[][]) DefineGlobalMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type[], Type[], Type[][], Type[][])

使用指定的名称、属性、调用约定、返回类型、返回类型的自定义修饰符、参数类型以及参数类型的自定义修饰符定义一个全局方法。Defines a global method with the specified name, attributes, calling convention, return type, custom modifiers for the return type, parameter types, and custom modifiers for the parameter types.

DefineGlobalMethod(String, MethodAttributes, Type, Type[]) DefineGlobalMethod(String, MethodAttributes, Type, Type[]) DefineGlobalMethod(String, MethodAttributes, Type, Type[]) DefineGlobalMethod(String, MethodAttributes, Type, Type[])

使用指定的名称、属性、返回类型和参数类型定义一个全局方法。Defines a global method with the specified name, attributes, return type, and parameter types.

DefineInitializedData(String, Byte[], FieldAttributes) DefineInitializedData(String, Byte[], FieldAttributes) DefineInitializedData(String, Byte[], FieldAttributes) DefineInitializedData(String, Byte[], FieldAttributes)

在可移植可执行 (PE) 文件的 .sdata 部分定义已初始化的数据字段。Defines an initialized data field in the .sdata section of the portable executable (PE) file.

DefineManifestResource(String, Stream, ResourceAttributes) DefineManifestResource(String, Stream, ResourceAttributes) DefineManifestResource(String, Stream, ResourceAttributes) DefineManifestResource(String, Stream, ResourceAttributes)

定义表示要在动态程序集中嵌入的清单资源的二进制大对象 (BLOB)。Defines a binary large object (BLOB) that represents a manifest resource to be embedded in the dynamic assembly.

DefinePInvokeMethod(String, String, MethodAttributes, CallingConventions, Type, Type[], CallingConvention, CharSet) DefinePInvokeMethod(String, String, MethodAttributes, CallingConventions, Type, Type[], CallingConvention, CharSet) DefinePInvokeMethod(String, String, MethodAttributes, CallingConventions, Type, Type[], CallingConvention, CharSet) DefinePInvokeMethod(String, String, MethodAttributes, CallingConventions, Type, Type[], CallingConvention, CharSet)

使用指定的名称、定义方法的 DLL 的名称、方法的属性、方法的调用约定、方法的返回类型、方法的参数类型以及 PInvoke 标志定义一个 PInvoke 方法。Defines a PInvoke method with the specified name, the name of the DLL in which the method is defined, the attributes of the method, the calling convention of the method, the return type of the method, the types of the parameters of the method, and the PInvoke flags.

DefinePInvokeMethod(String, String, String, MethodAttributes, CallingConventions, Type, Type[], CallingConvention, CharSet) DefinePInvokeMethod(String, String, String, MethodAttributes, CallingConventions, Type, Type[], CallingConvention, CharSet) DefinePInvokeMethod(String, String, String, MethodAttributes, CallingConventions, Type, Type[], CallingConvention, CharSet) DefinePInvokeMethod(String, String, String, MethodAttributes, CallingConventions, Type, Type[], CallingConvention, CharSet)

使用指定的名称、定义方法的 DLL 的名称、方法的属性、方法的调用约定、方法的返回类型、方法的参数类型以及 PInvoke 标志定义一个 PInvoke 方法。Defines a PInvoke method with the specified name, the name of the DLL in which the method is defined, the attributes of the method, the calling convention of the method, the return type of the method, the types of the parameters of the method, and the PInvoke flags.

DefineResource(String, String) DefineResource(String, String) DefineResource(String, String) DefineResource(String, String)

定义要存储在此模块中的已命名托管嵌入资源。Defines the named managed embedded resource to be stored in this module.

DefineResource(String, String, ResourceAttributes) DefineResource(String, String, ResourceAttributes) DefineResource(String, String, ResourceAttributes) DefineResource(String, String, ResourceAttributes)

用给定的特性定义存储在此模块中的已命名托管嵌入资源。Defines the named managed embedded resource with the given attributes that is to be stored in this module.

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

在此模块中用指定的名称为私有类型构造 TypeBuilderConstructs a TypeBuilder for a private type with the specified name in this module.

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

在给定类型名称和类型特性的情况下,构造 TypeBuilderConstructs a TypeBuilder given the type name and the type attributes.

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

在给定类型名称、类型特性和已定义类型扩展的类型的情况下,构造 TypeBuilderConstructs a TypeBuilder given type name, its attributes, and the type that the defined type extends.

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

在给定类型名称、特性、已定义类型扩展的类型和类型的总大小的情况下,构造 TypeBuilderConstructs 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)

在给定类型名称、特性、已定义类型扩展的类型和类型的封装大小的情况下,构造 TypeBuilderConstructs 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, Type, PackingSize, Int32) DefineType(String, TypeAttributes, Type, PackingSize, Int32) DefineType(String, TypeAttributes, Type, PackingSize, Int32) DefineType(String, TypeAttributes, Type, PackingSize, Int32)

在给定类型名称、特性、已定义类型扩展的类型,已定义类型的封装大小和已定义类型的总大小的情况下,构造 TypeBuilderConstructs 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[])

在给定类型名称、特性、已定义类型扩展的类型和已定义类型实现的接口的情况下,构造 TypeBuilderConstructs a TypeBuilder given the type name, attributes, the type that the defined type extends, and the interfaces that the defined type implements.

DefineUninitializedData(String, Int32, FieldAttributes) DefineUninitializedData(String, Int32, FieldAttributes) DefineUninitializedData(String, Int32, FieldAttributes) DefineUninitializedData(String, Int32, FieldAttributes)

在可移植可执行 (PE) 文件的 .sdata 部分定义未初始化的数据字段。Defines an uninitialized data field in the .sdata section of the portable executable (PE) file.

DefineUnmanagedResource(Byte[]) DefineUnmanagedResource(Byte[]) DefineUnmanagedResource(Byte[]) DefineUnmanagedResource(Byte[])

已知不透明的字节二进制大对象 (BLOB),定义非托管嵌入资源。Defines an unmanaged embedded resource given an opaque binary large object (BLOB) of bytes.

DefineUnmanagedResource(String) DefineUnmanagedResource(String) DefineUnmanagedResource(String) DefineUnmanagedResource(String)

在给定 Win32 资源文件名称的情况下,定义非托管资源。Defines an unmanaged resource given the name of Win32 resource file.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to the specified object.

FindTypes(TypeFilter, Object) FindTypes(TypeFilter, Object) FindTypes(TypeFilter, Object) FindTypes(TypeFilter, Object)

返回给定筛选器和筛选条件接受的类数组。Returns an array of classes accepted by the given filter and filter criteria.

(Inherited from Module)
GetArrayMethod(Type, String, CallingConventions, Type, Type[]) GetArrayMethod(Type, String, CallingConventions, Type, Type[]) GetArrayMethod(Type, String, CallingConventions, Type, Type[]) GetArrayMethod(Type, String, CallingConventions, Type, Type[])

返回数组类上的命名方法。Returns the named method on an array class.

GetArrayMethodToken(Type, String, CallingConventions, Type, Type[]) GetArrayMethodToken(Type, String, CallingConventions, Type, Type[]) GetArrayMethodToken(Type, String, CallingConventions, Type, Type[]) GetArrayMethodToken(Type, String, CallingConventions, Type, Type[])

返回数组类上的命名方法的标记。Returns the token for the named method on an array class.

GetConstructorToken(ConstructorInfo) GetConstructorToken(ConstructorInfo) GetConstructorToken(ConstructorInfo) GetConstructorToken(ConstructorInfo)

返回用于标识此模块内的指定构造函数的标记。Returns the token used to identify the specified constructor within this module.

GetConstructorToken(ConstructorInfo, IEnumerable<Type>) GetConstructorToken(ConstructorInfo, IEnumerable<Type>) GetConstructorToken(ConstructorInfo, IEnumerable<Type>) GetConstructorToken(ConstructorInfo, IEnumerable<Type>)

返回在此模块用于标识具有指定的特性和参数类型的构造函数的标记。Returns the token used to identify the constructor that has the specified attributes and parameter types within this module.

GetCustomAttributes(Boolean) GetCustomAttributes(Boolean) GetCustomAttributes(Boolean) GetCustomAttributes(Boolean)

返回已应用于当前 ModuleBuilder 的所有自定义属性。Returns all the custom attributes that have been applied to the current ModuleBuilder.

GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean)

返回已应用于当前 ModuleBuilder 且派生自指定特性类型的所有自定义特性。Returns all the custom attributes that have been applied to the current ModuleBuilder, and that derive from a specified attribute type.

GetCustomAttributesData() GetCustomAttributesData() GetCustomAttributesData() GetCustomAttributesData()

返回有关已应用于当前 ModuleBuilder(表示为 CustomAttributeData 对象)的特性的信息。Returns information about the attributes that have been applied to the current ModuleBuilder, expressed as CustomAttributeData objects.

GetField(String) GetField(String) GetField(String) GetField(String)

返回具有指定名称的方法。Returns a field having the specified name.

(Inherited from Module)
GetField(String, BindingFlags) GetField(String, BindingFlags) GetField(String, BindingFlags) GetField(String, BindingFlags)

返回在可移植可执行 (PE) 文件的 .sdata 区域中定义的、具有指定名称和绑定特性的模块级字段。Returns a module-level field, defined in the .sdata region of the portable executable (PE) file, that has the specified name and binding attributes.

GetFields() GetFields() GetFields() GetFields()

返回在模块上定义的全局字段。Returns the global fields defined on the module.

(Inherited from Module)
GetFields(BindingFlags) GetFields(BindingFlags) GetFields(BindingFlags) GetFields(BindingFlags)

返回在可移植可执行 (PE) 文件的 .sdata 区域中定义的、与指定绑定标志匹配的所有字段。Returns all fields defined in the .sdata region of the portable executable (PE) file that match the specified binding flags.

GetFieldToken(FieldInfo) GetFieldToken(FieldInfo) GetFieldToken(FieldInfo) GetFieldToken(FieldInfo)

返回用于标识此模块内的指定字段的标记。Returns the token used to identify the specified field within this module.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

GetMethod(String) GetMethod(String) GetMethod(String) GetMethod(String)

返回具有指定名称的方法。Returns a method having the specified name.

(Inherited from Module)
GetMethod(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) GetMethod(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) GetMethod(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) GetMethod(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

返回具有指定名称、绑定信息、调用约定和参数类型及修饰符的方法。Returns a method having the specified name, binding information, calling convention, and parameter types and modifiers.

(Inherited from Module)
GetMethod(String, Type[]) GetMethod(String, Type[]) GetMethod(String, Type[]) GetMethod(String, Type[])

返回具有指定名称和参数类型的方法。Returns a method having the specified name and parameter types.

(Inherited from Module)
GetMethodImpl(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) GetMethodImpl(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) GetMethodImpl(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[]) GetMethodImpl(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

返回符合指定条件的模块级方法。Returns the module-level method that matches the specified criteria.

GetMethods() GetMethods() GetMethods() GetMethods()

返回在模块中定义的全局方法。Returns the global methods defined on the module.

(Inherited from Module)
GetMethods(BindingFlags) GetMethods(BindingFlags) GetMethods(BindingFlags) GetMethods(BindingFlags)

返回已在模块级别上为当前 ModuleBuilder 定义并与指定的绑定标志匹配的所有方法。Returns all the methods that have been defined at the module level for the current ModuleBuilder, and that match the specified binding flags.

GetMethodToken(MethodInfo) GetMethodToken(MethodInfo) GetMethodToken(MethodInfo) GetMethodToken(MethodInfo)

返回用于标识此模块内指定方法的标记。Returns the token used to identify the specified method within this module.

GetMethodToken(MethodInfo, IEnumerable<Type>) GetMethodToken(MethodInfo, IEnumerable<Type>) GetMethodToken(MethodInfo, IEnumerable<Type>) GetMethodToken(MethodInfo, IEnumerable<Type>)

返回在此模块用于标识具有指定的特性和参数类型的方法的标记。Returns the token used to identify the method that has the specified attributes and parameter types within this module.

GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

提供序列化对象的 ISerializable 实现。Provides an ISerializable implementation for serialized objects.

(Inherited from Module)
GetPEKind(PortableExecutableKinds, ImageFileMachine) GetPEKind(PortableExecutableKinds, ImageFileMachine) GetPEKind(PortableExecutableKinds, ImageFileMachine) GetPEKind(PortableExecutableKinds, ImageFileMachine)

获取一对值,这一对值指示某个模块中代码的性质和该模块的目标平台。Gets a pair of values indicating the nature of the code in a module and the platform targeted by the module.

GetSignatureToken(Byte[], Int32) GetSignatureToken(Byte[], Int32) GetSignatureToken(Byte[], Int32) GetSignatureToken(Byte[], Int32)

为具有指定字符数组和签名长度的签名定义标记。Defines a token for the signature that has the specified character array and signature length.

GetSignatureToken(SignatureHelper) GetSignatureToken(SignatureHelper) GetSignatureToken(SignatureHelper) GetSignatureToken(SignatureHelper)

为由指定的 SignatureHelper 定义的签名定义标记。Defines a token for the signature that is defined by the specified SignatureHelper.

GetSignerCertificate() GetSignerCertificate() GetSignerCertificate() GetSignerCertificate()

返回与证书(包括在此模块所属的程序集的验证码签名中)对应的 X509Certificate 对象。Returns an X509Certificate object corresponding to the certificate included in the Authenticode signature of the assembly which this module belongs to. 如果此程序集没有进行验证码签名,则返回 nullIf the assembly has not been Authenticode signed, null is returned.

GetStringConstant(String) GetStringConstant(String) GetStringConstant(String) GetStringConstant(String)

返回模块常量池中给定字符串的标记。Returns the token of the given string in the module's constant pool.

GetSymWriter() GetSymWriter() GetSymWriter() GetSymWriter()

返回与此动态模块关联的符号编写器。Returns the symbol writer associated with this dynamic module.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
GetType(String) GetType(String) GetType(String) GetType(String)

获取模块中定义的命名类型。Gets the named type defined in the module.

GetType(String, Boolean) GetType(String, Boolean) GetType(String, Boolean) GetType(String, Boolean)

获取模块中定义的命名类型,可以忽略类型名称的大小写。Gets the named type defined in the module, optionally ignoring the case of the type name.

GetType(String, Boolean, Boolean) GetType(String, Boolean, Boolean) GetType(String, Boolean, Boolean) GetType(String, Boolean, Boolean)

获取模块中定义的命名类型,可以忽略类型名称的大小写。Gets the named type defined in the module, optionally ignoring the case of the type name. 如果未找到该类型,则可选择引发异常。Optionally throws an exception if the type is not found.

GetTypes() GetTypes() GetTypes() GetTypes()

返回在此模块内定义的所有类。Returns all the classes defined within this module.

GetTypeToken(String) GetTypeToken(String) GetTypeToken(String) GetTypeToken(String)

返回用于标识具有指定名称的类型的标记。Returns the token used to identify the type with the specified name.

GetTypeToken(Type) GetTypeToken(Type) GetTypeToken(Type) GetTypeToken(Type)

返回用于标识此模块内的指定类型的标记。Returns the token used to identify the specified type within this module.

IsDefined(Type, Boolean) IsDefined(Type, Boolean) IsDefined(Type, Boolean) IsDefined(Type, Boolean)

返回一个值,该值指示是否已将指定的特性类型应用于此模块。Returns a value that indicates whether the specified attribute type has been applied to this module.

IsResource() IsResource() IsResource() IsResource()

获取一个值,该值指示此对象是否是资源。Gets a value indicating whether the object is a resource.

IsTransient() IsTransient() IsTransient() IsTransient()

返回一个值,该值指示此动态模块是否为瞬态的。Returns a value that indicates whether this dynamic module is transient.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ResolveField(Int32) ResolveField(Int32) ResolveField(Int32) ResolveField(Int32)

返回由指定的元数据令牌标识的字段。Returns the field identified by the specified metadata token.

(Inherited from Module)
ResolveField(Int32, Type[], Type[]) ResolveField(Int32, Type[], Type[]) ResolveField(Int32, Type[], Type[]) ResolveField(Int32, Type[], Type[])

在由指定的泛型类型参数定义的上下文中,返回由指定的元数据令牌标识的字段。Returns the field identified by the specified metadata token, in the context defined by the specified generic type parameters.

ResolveMember(Int32) ResolveMember(Int32) ResolveMember(Int32) ResolveMember(Int32)

返回由指定的元数据令牌标识的类型或成员。Returns the type or member identified by the specified metadata token.

(Inherited from Module)
ResolveMember(Int32, Type[], Type[]) ResolveMember(Int32, Type[], Type[]) ResolveMember(Int32, Type[], Type[]) ResolveMember(Int32, Type[], Type[])

在由指定的泛型类型参数定义的上下文中,返回由指定的元数据令牌标识的类型或成员。Returns the type or member identified by the specified metadata token, in the context defined by the specified generic type parameters.

ResolveMethod(Int32) ResolveMethod(Int32) ResolveMethod(Int32) ResolveMethod(Int32)

返回由指定的元数据令牌标识的方法或构造函数。Returns the method or constructor identified by the specified metadata token.

(Inherited from Module)
ResolveMethod(Int32, Type[], Type[]) ResolveMethod(Int32, Type[], Type[]) ResolveMethod(Int32, Type[], Type[]) ResolveMethod(Int32, Type[], Type[])

在由指定的泛型类型参数定义的上下文中,返回由指定的元数据令牌标识的方法或构造函数。Returns the method or constructor identified by the specified metadata token, in the context defined by the specified generic type parameters.

ResolveSignature(Int32) ResolveSignature(Int32) ResolveSignature(Int32) ResolveSignature(Int32)

返回由元数据令牌标识的签名 Blob。Returns the signature blob identified by a metadata token.

ResolveString(Int32) ResolveString(Int32) ResolveString(Int32) ResolveString(Int32)

返回由指定元数据令牌标识的字符串。Returns the string identified by the specified metadata token.

ResolveType(Int32) ResolveType(Int32) ResolveType(Int32) ResolveType(Int32)

返回由指定的元数据令牌标识的类型。Returns the type identified by the specified metadata token.

(Inherited from Module)
ResolveType(Int32, Type[], Type[]) ResolveType(Int32, Type[], Type[]) ResolveType(Int32, Type[], Type[]) ResolveType(Int32, Type[], Type[])

在由指定的泛型类型参数定义的上下文中,返回由指定的元数据令牌标识的类型。Returns the type identified by the specified metadata token, in the context defined by the specified generic type parameters.

SetCustomAttribute(ConstructorInfo, Byte[]) SetCustomAttribute(ConstructorInfo, Byte[]) SetCustomAttribute(ConstructorInfo, Byte[]) SetCustomAttribute(ConstructorInfo, Byte[])

使用表示自定义属性的指定二进制大对象 (BLOB) 向此模块应用该属性。Applies a custom attribute to this module by using a specified binary large object (BLOB) that represents the attribute.

SetCustomAttribute(CustomAttributeBuilder) SetCustomAttribute(CustomAttributeBuilder) SetCustomAttribute(CustomAttributeBuilder) SetCustomAttribute(CustomAttributeBuilder)

使用自定义属性生成器向此模块应用自定义属性。Applies a custom attribute to this module by using a custom attribute builder.

SetSymCustomAttribute(String, Byte[]) SetSymCustomAttribute(String, Byte[]) SetSymCustomAttribute(String, Byte[]) SetSymCustomAttribute(String, Byte[])

此方法不执行任何操作。This method does nothing.

SetUserEntryPoint(MethodInfo) SetUserEntryPoint(MethodInfo) SetUserEntryPoint(MethodInfo) SetUserEntryPoint(MethodInfo)

设置用户入口点。Sets the user entry point.

ToString() ToString() ToString() ToString()

返回模块的名称。Returns the name of the module.

(Inherited from Module)

显式界面实现

ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean) Inherited from Module
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) Inherited from Module
ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean) Inherited from Module
_Module.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Module.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Module.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Module.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Module)
_Module.GetTypeInfo(UInt32, UInt32, IntPtr) _Module.GetTypeInfo(UInt32, UInt32, IntPtr) _Module.GetTypeInfo(UInt32, UInt32, IntPtr) _Module.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can then be used to get the type information for an interface.

(Inherited from Module)
_Module.GetTypeInfoCount(UInt32) _Module.GetTypeInfoCount(UInt32) _Module.GetTypeInfoCount(UInt32) _Module.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Module)
_Module.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Module.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Module.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Module.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(Inherited from Module)
_ModuleBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _ModuleBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _ModuleBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _ModuleBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

有关此成员的说明,请参见 GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)For a description of this member, see GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr).

_ModuleBuilder.GetTypeInfo(UInt32, UInt32, IntPtr) _ModuleBuilder.GetTypeInfo(UInt32, UInt32, IntPtr) _ModuleBuilder.GetTypeInfo(UInt32, UInt32, IntPtr) _ModuleBuilder.GetTypeInfo(UInt32, UInt32, IntPtr)

有关此成员的说明,请参见 GetTypeInfo(UInt32, UInt32, IntPtr)For a description of this member, see GetTypeInfo(UInt32, UInt32, IntPtr).

_ModuleBuilder.GetTypeInfoCount(UInt32) _ModuleBuilder.GetTypeInfoCount(UInt32) _ModuleBuilder.GetTypeInfoCount(UInt32) _ModuleBuilder.GetTypeInfoCount(UInt32)

有关此成员的说明,请参见 GetTypeInfoCount(UInt32)For a description of this member, see GetTypeInfoCount(UInt32).

_ModuleBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ModuleBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ModuleBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ModuleBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

有关此成员的说明,请参见 Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)For a description of this member, see Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr).

扩展方法

GetCustomAttribute(Module, Type) GetCustomAttribute(Module, Type) GetCustomAttribute(Module, Type) GetCustomAttribute(Module, Type)

检索应用于指定模块的指定类型的自定义特性。Retrieves a custom attribute of a specified type that is applied to a specified module.

GetCustomAttribute<T>(Module) GetCustomAttribute<T>(Module) GetCustomAttribute<T>(Module) GetCustomAttribute<T>(Module)

检索应用于指定模块的指定类型的自定义特性。Retrieves a custom attribute of a specified type that is applied to a specified module.

GetCustomAttributes(Module) GetCustomAttributes(Module) GetCustomAttributes(Module) GetCustomAttributes(Module)

检索应用于指定模块的自定义特性集合。Retrieves a collection of custom attributes that are applied to a specified module.

GetCustomAttributes(Module, Type) GetCustomAttributes(Module, Type) GetCustomAttributes(Module, Type) GetCustomAttributes(Module, Type)

检索应用于指定模块的指定类型的自定义特性集合。Retrieves a collection of custom attributes of a specified type that are applied to a specified module.

GetCustomAttributes<T>(Module) GetCustomAttributes<T>(Module) GetCustomAttributes<T>(Module) GetCustomAttributes<T>(Module)

检索应用于指定模块的指定类型的自定义特性集合。Retrieves a collection of custom attributes of a specified type that are applied to a specified module.

IsDefined(Module, Type) IsDefined(Module, Type) IsDefined(Module, Type) IsDefined(Module, Type)

确定是否将指定类型的任何自定义属性应用于指定的模块。Indicates whether custom attributes of a specified type are applied to a specified module.

GetModuleVersionId(Module) GetModuleVersionId(Module) GetModuleVersionId(Module) GetModuleVersionId(Module)
HasModuleVersionId(Module) HasModuleVersionId(Module) HasModuleVersionId(Module) HasModuleVersionId(Module)

适用于