ModuleBuilder.GetType 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取模块中定义的命名类型。
重载
| 名称 | 说明 |
|---|---|
| GetType(String) |
获取模块中定义的命名类型。 |
| GetType(String, Boolean) |
获取模块中定义的命名类型,可以选择忽略类型名称大小写。 |
| GetType(String, Boolean, Boolean) |
获取模块中定义的命名类型,可以选择忽略类型名称大小写。 (可选)如果未找到类型,则引发异常。 |
GetType(String)
- Source:
- ModuleBuilder.cs
获取模块中定义的命名类型。
public:
override Type ^ GetType(System::String ^ className);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")]
public override Type? GetType(string className);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
public override Type? GetType(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);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")>]
override this.GetType : string -> Type
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")>]
override this.GetType : string -> Type
override this.GetType : string -> Type
[<System.Runtime.InteropServices.ComVisible(true)>]
override this.GetType : string -> Type
Public Overrides Function GetType (className As String) As Type
参数
返回
请求的类型(如果该类型在此模块中定义);否则,为 null.
- 属性
例外
长度为 className 零或大于 1023。
className 是 null。
请求 Type 的不是公共对象,调用方不必 ReflectionPermission 反映当前程序集外部的非公共对象。
调用类初始值设定项并引发异常。
加载时 Type遇到错误。
注解
请勿使用此方法生成数组类型、指针类型或 byref 类型。 请改用TypeBuilder.MakeArrayType和TypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType方法。
适用于
GetType(String, Boolean)
- Source:
- ModuleBuilder.cs
获取模块中定义的命名类型,可以选择忽略类型名称大小写。
public:
override Type ^ GetType(System::String ^ className, bool ignoreCase);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")]
public override Type? GetType(string className, bool ignoreCase);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
public override Type? GetType(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);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")>]
override this.GetType : string * bool -> Type
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")>]
override this.GetType : string * bool -> Type
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
参数
- ignoreCase
- Boolean
如果 true,则搜索不区分大小写。 如果 false,搜索区分大小写。
返回
请求的类型(如果该类型在此模块中定义);否则,为 null.
- 属性
例外
长度为 className 零或大于 1023。
className 是 null。
请求 Type 的不是公共对象,调用方不必 ReflectionPermission 反映当前程序集外部的非公共对象。
调用类初始值设定项并引发异常。
注解
请勿使用此方法生成数组类型、指针类型或 byref 类型。 请改用TypeBuilder.MakeArrayType和TypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType方法。
适用于
GetType(String, Boolean, Boolean)
- Source:
- ModuleBuilder.cs
获取模块中定义的命名类型,可以选择忽略类型名称大小写。 (可选)如果未找到类型,则引发异常。
public:
override Type ^ GetType(System::String ^ className, bool throwOnError, bool ignoreCase);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")]
public override Type? GetType(string className, bool throwOnError, bool ignoreCase);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
public override Type? GetType(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);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed by trimming. If the type name is a string literal, consider using Type.GetType instead.")>]
override this.GetType : string * bool * bool -> Type
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")>]
override this.GetType : string * bool * bool -> Type
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
参数
- throwOnError
- Boolean
true 如果找不到类型,则引发异常; falsenull返回 。
- ignoreCase
- Boolean
如果 true,则搜索不区分大小写。 如果 false,搜索区分大小写。
返回
指定类型(如果该类型在此模块中声明);否则,为 null.
- 属性
例外
长度为 className 零或大于 1023。
className 是 null。
请求 Type 的不是公共对象,调用方不必 ReflectionPermission 反映当前程序集外部的非公共对象。
调用类初始值设定项并引发异常。
throwOnError 是 true 且找不到指定的类型。
注解
该 throwOnError 参数仅影响找不到类型时发生的情况。 它不会影响可能引发的任何其他异常。 具体而言,如果找到类型但无法加载,即使为 <
请勿使用此方法生成数组类型、指针类型或 byref 类型。 请改用TypeBuilder.MakeArrayType和TypeBuilder.MakePointerTypeTypeBuilder.MakeByRefType方法。