Module 類別

定義

在模組上執行反映。

public ref class Module abstract
public ref class Module abstract : System::Reflection::ICustomAttributeProvider, System::Runtime::Serialization::ISerializable
public ref class Module abstract : System::Reflection::ICustomAttributeProvider
public ref class Module : System::Reflection::ICustomAttributeProvider, System::Runtime::InteropServices::_Module, System::Runtime::Serialization::ISerializable
public ref class Module abstract : System::Reflection::ICustomAttributeProvider, System::Runtime::InteropServices::_Module, System::Runtime::Serialization::ISerializable
public abstract class Module
public abstract class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.Serialization.ISerializable
public abstract class Module : System.Reflection.ICustomAttributeProvider
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Serializable]
public class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.InteropServices._Module, System.Runtime.Serialization.ISerializable
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.InteropServices._Module, System.Runtime.Serialization.ISerializable
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.InteropServices._Module, System.Runtime.Serialization.ISerializable
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.Serialization.ISerializable
type Module = class
type Module = class
    interface ICustomAttributeProvider
    interface ISerializable
type Module = class
    interface ICustomAttributeProvider
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Serializable>]
type Module = class
    interface _Module
    interface ISerializable
    interface ICustomAttributeProvider
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Module = class
    interface _Module
    interface ISerializable
    interface ICustomAttributeProvider
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Module = class
    interface ISerializable
    interface ICustomAttributeProvider
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Module = class
    interface ISerializable
    interface ICustomAttributeProvider
    interface _Module
Public MustInherit Class Module
Public MustInherit Class Module
Implements ICustomAttributeProvider, ISerializable
Public MustInherit Class Module
Implements ICustomAttributeProvider
Public Class Module
Implements _Module, ICustomAttributeProvider, ISerializable
Public MustInherit Class Module
Implements _Module, ICustomAttributeProvider, ISerializable
繼承
Module
衍生
屬性
實作

範例

下列程式碼範例示範如何使用反映來取得模組的相關資訊:

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

備註

模組是包含一或多個類別和介面的可攜式可執行檔,例如type.dll或application.exe。 多個命名空間可能包含在單一模組中,並且命名空間可以擴展多個模組。

已部署為一個單元的一個或多個模組會組成組件。 如需使用多個模組建立元件的詳細資訊,請參閱 多檔案元件

請注意,.NET Framework模組與 Visual Basic 中的模組不同,由程式設計人員用來組織應用程式中的函式和副程式。

建構函式

Module()

初始化 Module 類別的新執行個體。

欄位

FilterTypeName

TypeFilter 物件,其會根據名稱來篩選此模組中定義的類型清單。 這個欄位會區分大小寫且為唯讀狀態。

FilterTypeNameIgnoreCase

TypeFilter 物件,其會根據名稱來篩選此模組中定義的類型清單。 這個欄位是不區分大小寫且為唯讀狀態。

屬性

Assembly

取得這個 Assembly 執行個體的合適 Module

CustomAttributes

取得包含此模組之自訂屬性的集合。

FullyQualifiedName

取得表示這個模組完整名稱和路徑的字串。

MDStreamVersion

取得中繼資料流的版本。

MetadataToken

取得語彙基元,可識別中繼資料中的模組。

ModuleHandle

取得模組的控制代碼。

ModuleVersionId

取得可用來區別兩個模組版本的全域唯一識別碼 (UUID)。

Name

取得 String,表示路徑已移除的模組名稱。

ScopeName

取得表示模組名稱的字串。

方法

Equals(Object)

判斷這個模組和指定的物件是否相等。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
FindTypes(TypeFilter, Object)

傳回指定篩選器和篩選準則所接受的類別陣列。

GetCustomAttributes(Boolean)

傳回所有自訂屬性。

GetCustomAttributes(Type, Boolean)

取得指定型別的自訂屬性。

GetCustomAttributesData()

傳回目前模組的 CustomAttributeData 物件清單,這些物件可用於僅限反映的內容中。

GetField(String)

傳回具有指定名稱的欄位。

GetField(String, BindingFlags)

傳回具有指定名稱和繫結屬性的欄位。

GetFields()

傳回模組中定義的全域欄位。

GetFields(BindingFlags)

傳回定義於模組上且符合指定繫結旗標的全域欄位。

GetHashCode()

傳回這個執行個體的雜湊碼。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetMethod(String)

傳回具有指定名稱的方法。

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

傳回方法,該方法具有指定的名稱、繫結資訊、呼叫慣例和參數類型及修飾詞。

GetMethod(String, Type[])

傳回具有指定名稱及參數類型的方法。

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

傳回方法實作,根據指定準則。

GetMethods()

傳回模組中定義的全域方法。

GetMethods(BindingFlags)

傳回定義於模組上且符合指定繫結旗標的全域方法。

GetObjectData(SerializationInfo, StreamingContext)

提供序列化物件的 ISerializable 實作。

GetPEKind(PortableExecutableKinds, ImageFileMachine)

取得值組,表示模組中的程式碼性質,以及模組的目標平台。

GetSignerCertificate()

傳回 X509Certificate 物件,對應到這個模組所屬之組件的 Authenticode 簽章中所包含的憑證。 如果組件還未經 Authenticode 簽名,則傳回 null

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetType(String)

執行區分大小寫的搜尋,傳回指定的類型。

GetType(String, Boolean)

傳回指定的類型,使用指定的大小寫搜尋模組。

GetType(String, Boolean, Boolean)

傳回指定的型別,並指定是否要對模組進行區分大小寫的搜尋,以及是否要在找不到型別時擲回例外狀況。

GetTypes()

傳回此模組中定義的所有類型。

IsDefined(Type, Boolean)

傳回值,這個值表示指定的屬性型別是否已套用至此模組。

IsResource()

取得值,指出物件是否為資源。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ResolveField(Int32)

傳回指定之中繼資料語彙基元所識別的欄位。

ResolveField(Int32, Type[], Type[])

以指定之泛型型別參數所定義的內容,傳回指定之中繼資料語彙基元所識別的欄位。

ResolveMember(Int32)

傳回指定之中繼資料語彙基元所識別的型別或成員。

ResolveMember(Int32, Type[], Type[])

以指定之泛型型別參數所定義的內容,傳回指定之中繼資料語彙基元所識別的型別或成員。

ResolveMethod(Int32)

傳回指定之中繼資料語彙基元所識別的方法或建構函式。

ResolveMethod(Int32, Type[], Type[])

以指定之泛型型別參數所定義的內容,傳回指定之中繼資料語彙基元所識別的方法或建構函式。

ResolveSignature(Int32)

傳回中繼資料語彙基元所識別的簽章 Blob (二進位大型物件)。

ResolveString(Int32)

傳回指定之中繼資料語彙基元所識別的字串。

ResolveType(Int32)

傳回指定之中繼資料語彙基元所識別的型別。

ResolveType(Int32, Type[], Type[])

以指定之泛型型別參數所定義的內容,傳回指定之中繼資料語彙基元所識別的型別。

ToString()

傳回模組名稱。

運算子

Equality(Module, Module)

表示兩個 Module 物件是否相等。

Inequality(Module, Module)

表示兩個 Module 物件是否不相等。

明確介面實作

_Module.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

_Module.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。

_Module.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

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

提供物件所公開的屬性和方法的存取權。

ICustomAttributeProvider.GetCustomAttributes(Boolean)

傳回這個成員中定義的所有自訂屬性的陣列 (但具名屬性除外),如果沒有自訂屬性,則傳回空陣列。

ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)

傳回這個成員中定義的自訂屬性陣列 (依類型識別),如果沒有該類型的自訂屬性,則傳回空陣列。

ICustomAttributeProvider.IsDefined(Type, Boolean)

指出此成員上是否有定義一個或多個 attributeType 執行個體。

擴充方法

GetCustomAttribute(Module, Type)

擷取指定型別的自訂屬性,此屬性套用至指定模組。

GetCustomAttribute<T>(Module)

擷取指定型別的自訂屬性,此屬性套用至指定模組。

GetCustomAttributes(Module)

擷取套用至指定模組的自訂屬性集合。

GetCustomAttributes(Module, Type)

擷取指定型別的自訂屬性集合,此集合套用至指定模組。

GetCustomAttributes<T>(Module)

擷取指定型別的自訂屬性集合,此集合套用至指定模組。

IsDefined(Module, Type)

指出是否將所指定型別的自訂屬性套用至指定的模組。

GetModuleVersionId(Module)

在模組上執行反映。

HasModuleVersionId(Module)

在模組上執行反映。

適用於