Module 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在模組上進行反射。
public ref class Module abstract
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 ref class Module abstract : System::Reflection::ICustomAttributeProvider
public ref class Module abstract : System::Reflection::ICustomAttributeProvider, System::Runtime::Serialization::ISerializable
public abstract class Module
[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
public abstract class Module : System.Reflection.ICustomAttributeProvider
public abstract class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.Serialization.ISerializable
type Module = class
[<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
type Module = class
interface ICustomAttributeProvider
type Module = class
interface ICustomAttributeProvider
interface ISerializable
Public MustInherit Class Module
Public Class Module
Implements _Module, ICustomAttributeProvider, ISerializable
Public MustInherit Class Module
Implements _Module, ICustomAttributeProvider, ISerializable
Public MustInherit Class Module
Implements ICustomAttributeProvider
Public MustInherit Class Module
Implements 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 中的模組不同,後者是程式設計師用來組織應用程式中的函式與子程式。
建構函式
| 名稱 | Description |
|---|---|
| Module() |
初始化 Module 類別的新執行個體。 |
欄位
| 名稱 | Description |
|---|---|
| FilterTypeName |
一個 |
| FilterTypeNameIgnoreCase |
一個 |
屬性
| 名稱 | Description |
|---|---|
| Assembly | |
| CustomAttributes |
會得到一個包含該模組自訂屬性的集合。 |
| FullyQualifiedName |
會得到一個字串,代表這個模組的完全限定名稱和路徑。 |
| MDStreamVersion |
取得元資料串流版本。 |
| MetadataToken |
會獲得一個標記,用來識別模組的元資料。 |
| ModuleHandle |
拿到模組的控制權。 |
| ModuleVersionId |
獲得一個通用唯一識別碼(UUID),可用來區分模組的兩個版本。 |
| Name |
會得到 |
| ScopeName |
會得到一個代表模組名稱的字串。 |
方法
操作員
| 名稱 | Description |
|---|---|
| Equality(Module, Module) |
表示兩個 Module 物體是否相等。 |
| Inequality(Module, Module) |
表示兩個 Module 物體是否不相等。 |
明確介面實作
| 名稱 | Description |
|---|---|
| _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) |
表示該成員是否定義了一個或多個 的 |
擴充方法
| 名稱 | Description |
|---|---|
| GetCustomAttribute(Module, Type) |
擷取指定型別的自訂屬性,套用到指定模組。 |
| GetCustomAttribute<T>(Module) |
擷取指定型別的自訂屬性,套用到指定模組。 |
| GetCustomAttributes(Module, Type) |
擷取一組指定型別的自訂屬性,這些屬性套用到指定模組上。 |
| GetCustomAttributes(Module) |
擷取一套套用到指定模組的自訂屬性集合。 |
| GetCustomAttributes<T>(Module) |
擷取一組指定型別的自訂屬性,這些屬性套用到指定模組上。 |
| IsDefined(Module, Type) |
表示是否套用特定類型的自訂屬性於特定模組。 |