Assembly.GetModule(String) 方法

定義

取得這個組件中的指定模組。

public:
 virtual System::Reflection::Module ^ GetModule(System::String ^ name);
public virtual System.Reflection.Module? GetModule (string name);
public virtual System.Reflection.Module GetModule (string name);
public System.Reflection.Module GetModule (string name);
abstract member GetModule : string -> System.Reflection.Module
override this.GetModule : string -> System.Reflection.Module
Public Overridable Function GetModule (name As String) As Module
Public Function GetModule (name As String) As Module

參數

name
String

所要求的模組名稱。

傳回

正在接受要求的模組,如果找不到模組,則為 null

實作

例外狀況

name 參數為 null

name 參數是空字串 ("")。

無法載入找到的檔案。

找不到 name

name 不是有效的組件。

備註

這個方法適用于檔案名。

命名空間中的 Reflection.Emit 類別會發出動態模組的範圍名稱。 範圍名稱可由 屬性決定 Module.ScopeName 。 傳遞您想要 Assembly.GetModule 的模組種類。 例如,如果您想要包含元件資訊清單的模組,請將模組的範圍名稱傳遞至 GetModule 。 否則,請傳遞模組的檔案名。 其中一個 Load 具有 byte[] 參數的方法所載入的元件只有一個模組,也就是資訊清單模組。 請一律使用範圍名稱搜尋這些模組。

您可以使用 從特定模組 Module.GetType 擷取型別。 在包含資訊清單的模組上呼叫 Module.GetType ,將不會起始整個元件的搜尋。 若要從元件擷取類型,不論其所在的模組為何,您都必須呼叫 Assembly.GetType

適用於