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
Imports System

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

備註

模組是可攜式的可執行檔,諸如 type.dll 或 application.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

取得這個 Assembly 執行個體的合適 ModuleGets 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 物件,對應到這個模組所屬之組件的 Authenticode 簽章中所包含的憑證。Returns an X509Certificate object corresponding to the certificate included in the Authenticode signature of the assembly which this module belongs to. 如果組件還未經 Authenticode 簽名,則傳回 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 的淺層複本 (Shallow Copy)。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)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。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.

適用於