ModuleBuilder.GetType 方法

定義

取得在模組中定義的具名型別。

多載

GetType(String)

取得在模組中定義的具名型別。

GetType(String, Boolean)

取得模組中定義的具名型別,選擇性地忽略型別名稱的大小寫。

GetType(String, Boolean, Boolean)

取得模組中定義的具名型別,選擇性地忽略型別名稱的大小寫。 如果找不到型別,則是選擇性的擲回例外狀況。

GetType(String)

來源:
ModuleBuilder.cs

取得在模組中定義的具名型別。

public:
 override Type ^ GetType(System::String ^ className);
public override Type? GetType (string className);
public override Type GetType (string className);
[System.Runtime.InteropServices.ComVisible(true)]
public override Type GetType (string className);
override this.GetType : string -> Type
[<System.Runtime.InteropServices.ComVisible(true)>]
override this.GetType : string -> Type
Public Overrides Function GetType (className As String) As Type

參數

className
String

要取得之 Type 的名稱。

傳回

如果此模組中已定義要求的型別則為該型別,否則為 null

屬性

例外狀況

className 的長度為零或大於 1023。

classNamenull

要求的 Type 是非公用的,而且呼叫端並沒有 ReflectionPermission 來反映目前組件之外的非公用物件。

叫用類別初始設定式並擲回例外狀況。

在載入 Type 時發生錯誤。

備註

請勿使用此方法來產生數位類型、指標類型或 byref 類型。 請改用 TypeBuilder.MakeArrayTypeTypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType 方法。

注意

從 .NET Framework 2.0 Service Pack 1 開始,此成員不再需要 ReflectionPermissionReflectionPermissionFlag.ReflectionEmit標。 (請參閱反映 Emit.) 中的安全性問題 若要使用這項功能,您的應用程式應以 .NET Framework 3.5 或更新版本為目標。

適用於

GetType(String, Boolean)

來源:
ModuleBuilder.cs

取得模組中定義的具名型別,選擇性地忽略型別名稱的大小寫。

public:
 override Type ^ GetType(System::String ^ className, bool ignoreCase);
public override Type? GetType (string className, bool ignoreCase);
public override Type GetType (string className, bool ignoreCase);
[System.Runtime.InteropServices.ComVisible(true)]
public override Type GetType (string className, bool ignoreCase);
override this.GetType : string * bool -> Type
[<System.Runtime.InteropServices.ComVisible(true)>]
override this.GetType : string * bool -> Type
Public Overrides Function GetType (className As String, ignoreCase As Boolean) As Type

參數

className
String

要取得之 Type 的名稱。

ignoreCase
Boolean

如果為 true,搜尋不區分大小寫。 如果為 false,搜尋會區分大小寫。

傳回

如果此模組中已定義要求的型別則為該型別,否則為 null

屬性

例外狀況

className 的長度為零或大於 1023。

classNamenull

要求的 Type 是非公用的,而且呼叫端並沒有 ReflectionPermission 來反映目前組件之外的非公用物件。

叫用類別初始設定式並擲回例外狀況。

備註

請勿使用此方法來產生數位類型、指標類型或 byref 類型。 請改用 TypeBuilder.MakeArrayTypeTypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType 方法。

注意

從 .NET Framework 2.0 Service Pack 1 開始,此成員不再需要 ReflectionPermissionReflectionPermissionFlag.ReflectionEmit標。 (請參閱反映 Emit.) 中的安全性問題 若要使用這項功能,您的應用程式應以 .NET Framework 3.5 或更新版本為目標。

適用於

GetType(String, Boolean, Boolean)

來源:
ModuleBuilder.cs

取得模組中定義的具名型別,選擇性地忽略型別名稱的大小寫。 如果找不到型別,則是選擇性的擲回例外狀況。

public:
 override Type ^ GetType(System::String ^ className, bool throwOnError, bool ignoreCase);
public override Type? GetType (string className, bool throwOnError, bool ignoreCase);
public override Type GetType (string className, bool throwOnError, bool ignoreCase);
[System.Runtime.InteropServices.ComVisible(true)]
public override Type GetType (string className, bool throwOnError, bool ignoreCase);
override this.GetType : string * bool * bool -> Type
[<System.Runtime.InteropServices.ComVisible(true)>]
override this.GetType : string * bool * bool -> Type
Public Overrides Function GetType (className As String, throwOnError As Boolean, ignoreCase As Boolean) As Type

參數

className
String

要取得之 Type 的名稱。

throwOnError
Boolean

true 表示找不到該類型時擲回例外狀況,而 false 則表示傳回 null

ignoreCase
Boolean

如果為 true,搜尋不區分大小寫。 如果為 false,搜尋會區分大小寫。

傳回

如果此模組中已宣告指定的型別則為該型別,否則為 null

屬性

例外狀況

className 的長度為零或大於 1023。

classNamenull

要求的 Type 是非公用的,而且呼叫端並沒有 ReflectionPermission 來反映目前組件之外的非公用物件。

叫用類別初始設定式並擲回例外狀況。

throwOnErrortrue,且找不到指定的型別。

備註

參數 throwOnError 只會影響找不到類型時會發生什麼情況。 它不會影響任何其他可能擲回的例外狀況。 特別是,如果找到型別但無法載入,TypeLoadException即使 為 false,也可以擲回throwOnError

請勿使用此方法來產生數位類型、指標類型或 byref 類型。 請改用 TypeBuilder.MakeArrayTypeTypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType 方法。

注意

從 .NET Framework 2.0 Service Pack 1 開始,此成員不再需要 ReflectionPermissionReflectionPermissionFlag.ReflectionEmit標。 (請參閱反映 Emit.) 中的安全性問題 若要使用這項功能,您的應用程式應以 .NET Framework 3.5 或更新版本為目標。

適用於