Module Module Module Module Class

定义

在模块上执行反射。Performs reflection on a module.

public ref class Module abstract : System::Reflection::ICustomAttributeProvider, System::Runtime::InteropServices::_Module, System::Runtime::Serialization::ISerializable
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public abstract class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.InteropServices._Module, System.Runtime.Serialization.ISerializable
type Module = class
    interface ISerializable
    interface ICustomAttributeProvider
    interface _Module
Public MustInherit Class Module
Implements _Module, ICustomAttributeProvider, ISerializable
继承
ModuleModuleModuleModule
派生
属性
实现

示例

下面的代码示例演示如何使用反射来获取有关模块的信息:The following code examples show how to use reflection to get information about modules:

using System.Reflection;
using System;
public class Program {

    public static void Main() {
        Class1 c1 = new Class1();
        //  Show the current module.
        Module m = c1.GetType().Module;
        Console.WriteLine("The current module is {0}.", m.Name);

        //  List all modules in the assembly.
        Assembly curAssembly = typeof(Program).Assembly;
        Console.WriteLine("The current executing assembly is {0}.", curAssembly);

        Module[] mods = curAssembly.GetModules();
        foreach (Module md in mods) {
            Console.WriteLine("This assembly contains the {0} module", md.Name);
        }
        Console.ReadLine();
    }
}
class Class1 {
}
Imports System.Reflection

Public Class Program
    Public Shared Sub Main()

        Dim c1 As New Class1

        ' Show the current module.

        ' Note the brackets around "[Module]" to differentiate 
        ' it from the Visual Basic "Module" keyword.
        Dim m As [Module] = c1.GetType().Module
        Console.WriteLine("The current module is {0}.", m.Name)

        ' List all modules in the assembly.
        Dim curAssembly As Assembly = GetType(Program).Assembly
        Console.WriteLine("The executing assembly is {0}.", curAssembly)

        Dim mods() As [Module] = curAssembly.GetModules()

        For Each md As [Module] In mods
            Console.WriteLine("This assembly contains the {0} module", md.Name)
        Next
        Console.ReadLine()
    End Sub


End Class
Class Class1

End Class

注解

模块是可移植的可执行文件,例如类型 .dll 或 setup.exe,其中包含一个或多个类和接口。A module is a portable executable file, such as type.dll or application.exe, consisting of one or more classes and interfaces. 单个模块可包含多个命名空间,而一个命名空间可跨越多个模块。There may be multiple namespaces contained in a single module, and a namespace may span multiple modules.

作为一个单元部署的一个或多个模块组成一个程序集。One or more modules deployed as a unit compose an assembly. 有关创建包含多个模块的程序集的信息,请参阅多文件程序集For information about creating an assembly with more than one module, see Multifile Assemblies.

请注意,.NET Framework 模块与 Visual Basic 中的模块不同,程序员使用它在应用程序中组织函数和子例程。Note that a .NET Framework module is not the same as a module in Visual Basic, which is used by a programmers to organize functions and subroutines in an application.

构造函数

Module() Module() Module() Module()

初始化 Module 类的新实例。Initializes a new instance of the Module class.

字段

FilterTypeName FilterTypeName FilterTypeName FilterTypeName

一个 TypeFilter 对象,该对象根据名称筛选在此模块中定义的类型列表。A TypeFilter object that filters the list of types defined in this module based upon the name. 此字段区分大小写且为只读。This field is case-sensitive and read-only.

FilterTypeNameIgnoreCase FilterTypeNameIgnoreCase FilterTypeNameIgnoreCase FilterTypeNameIgnoreCase

一个 TypeFilter 对象,该对象根据名称筛选在此模块中定义的类型列表。A TypeFilter object that filters the list of types defined in this module based upon the name. 此字段不区分大小写且为只读。This field is case-insensitive and read-only.

属性

Assembly Assembly Assembly Assembly

为此 Module 实例获取适当的 AssemblyGets the appropriate Assembly for this instance of Module.

CustomAttributes CustomAttributes CustomAttributes CustomAttributes

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

FullyQualifiedName FullyQualifiedName FullyQualifiedName FullyQualifiedName

获取表示此模块的完全限定名和路径的字符串。Gets 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 module in metadata.

ModuleHandle ModuleHandle ModuleHandle ModuleHandle

获取模块的图柄。Gets a handle for the 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

获取 String,它表示移除了路径的模块名。Gets a String representing the name of the module with the path removed.

ScopeName ScopeName ScopeName ScopeName

获取表示模块名的字符串。Gets a string representing the name of the module.

方法

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

确定此模块和指定的对象是否相等。Determines whether this module and the specified object are equal.

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.

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

返回所有自定义属性。Returns all custom attributes.

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

获取指定类型的自定义属性。Gets custom attributes of the specified type.

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

返回当前模块的 CustomAttributeData 对象列表,这些对象可以在只反射上下文中使用。Returns a list of CustomAttributeData objects for the current module, which can be used in the reflection-only context.

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

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

GetField(String, BindingFlags) GetField(String, BindingFlags) GetField(String, BindingFlags) GetField(String, BindingFlags)

返回具有指定名称和绑定特性的字段。Returns a field having the specified name and binding attributes.

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

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

GetFields(BindingFlags) GetFields(BindingFlags) GetFields(BindingFlags) GetFields(BindingFlags)

返回在与指定绑定标志匹配的模块上定义的全局字段。Returns the global fields defined on the module that match the specified binding flags.

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.

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.

GetMethod(String, Type[]) GetMethod(String, Type[]) GetMethod(String, Type[]) GetMethod(String, Type[])

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

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 method implementation in accordance with the specified criteria.

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

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

GetMethods(BindingFlags) GetMethods(BindingFlags) GetMethods(BindingFlags) GetMethods(BindingFlags)

返回在与指定的绑定标志匹配的模块上定义的全局方法。Returns the global methods defined on the module that match the specified binding flags.

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

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

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.

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.

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

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

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

返回指定的类型,执行区分大小写的搜索。Returns the specified type, performing a case-sensitive search.

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

返回指定的类型,通过指定的区分大小写搜索模块。Returns the specified type, searching the module with the specified case sensitivity.

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

返回指定的类型,指定是否对该模块进行区分大小写的搜索;如果找不到该类型,则指定是否引发异常。Returns the specified type, specifying whether to make a case-sensitive search of the module and whether to throw an exception if the type cannot be found.

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

返回在此模块中定义的所有类型。Returns all the types defined 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.

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.

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.

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.

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.

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.

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

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

操作员

Equality(Module, Module) Equality(Module, Module) Equality(Module, Module) Equality(Module, Module)

指示两个 Module 对象是否相等。Indicates whether two Module objects are equal.

Inequality(Module, Module) Inequality(Module, Module) Inequality(Module, Module) Inequality(Module, Module)

指示两个 Module 对象是否不相等。Indicates whether two Module objects are not equal.

显式界面实现

ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean)
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)
ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean)
_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.

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

_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).

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

扩展方法

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)

安全性

InheritanceDemand
完全信任继承者。for full trust for inheritors. 此类不能由部分信任的代码继承。This class cannot be inherited by partially trusted code.

适用于