RuntimeHelpers.PrepareMethod 方法

定义

准备一个要包含在受约束的执行区域 (CER) 中的方法。

重载

PrepareMethod(RuntimeMethodHandle)

准备一个要包含在受约束的执行区域 (CER) 中的方法。

PrepareMethod(RuntimeMethodHandle, RuntimeTypeHandle[])

准备一个要包含在受约束的执行区域 (CER) 中的具有指定实例化的方法。

PrepareMethod(RuntimeMethodHandle)

Source:
RuntimeHelpers.CoreCLR.cs
Source:
RuntimeHelpers.CoreCLR.cs
Source:
RuntimeHelpers.CoreCLR.cs

准备一个要包含在受约束的执行区域 (CER) 中的方法。

public:
 static void PrepareMethod(RuntimeMethodHandle method);
public static void PrepareMethod (RuntimeMethodHandle method);
[System.Security.SecurityCritical]
public static void PrepareMethod (RuntimeMethodHandle method);
static member PrepareMethod : RuntimeMethodHandle -> unit
[<System.Security.SecurityCritical>]
static member PrepareMethod : RuntimeMethodHandle -> unit
Public Shared Sub PrepareMethod (method As RuntimeMethodHandle)

参数

method
RuntimeMethodHandle

要准备的方法的句柄。

属性

注解

编译器使用 PrepareMethod(RuntimeMethodHandle) 方法处理在受约束的执行区域 (CER) 内进行的虚拟调用。 在 JIT 编译时,公共语言运行时通常没有关于虚拟调用目标的足够信息。 因此,运行时最初不会准备调用图的该段。 如果使用 CER 的代码在实际输入 CER 之前的任何时间点具有足够的知识来确定目标,则它可以调用 PrepareMethod(RuntimeMethodHandle) 来执行通常为以参数指定的方法生根的 CER 执行的相同运行时准备。

适用于

PrepareMethod(RuntimeMethodHandle, RuntimeTypeHandle[])

Source:
RuntimeHelpers.CoreCLR.cs
Source:
RuntimeHelpers.CoreCLR.cs
Source:
RuntimeHelpers.CoreCLR.cs

准备一个要包含在受约束的执行区域 (CER) 中的具有指定实例化的方法。

public:
 static void PrepareMethod(RuntimeMethodHandle method, cli::array <RuntimeTypeHandle> ^ instantiation);
public static void PrepareMethod (RuntimeMethodHandle method, RuntimeTypeHandle[]? instantiation);
[System.Security.SecurityCritical]
public static void PrepareMethod (RuntimeMethodHandle method, RuntimeTypeHandle[] instantiation);
public static void PrepareMethod (RuntimeMethodHandle method, RuntimeTypeHandle[] instantiation);
static member PrepareMethod : RuntimeMethodHandle * RuntimeTypeHandle[] -> unit
[<System.Security.SecurityCritical>]
static member PrepareMethod : RuntimeMethodHandle * RuntimeTypeHandle[] -> unit
Public Shared Sub PrepareMethod (method As RuntimeMethodHandle, instantiation As RuntimeTypeHandle())

参数

method
RuntimeMethodHandle

要准备的方法的句柄。

instantiation
RuntimeTypeHandle[]

要传递给该方法的实例化。

属性

注解

可以使用 方法为编译器 PrepareMethod(RuntimeMethodHandle, RuntimeTypeHandle[]) 提供泛型支持。 公共语言运行时无法准备受约束的执行区域, (CER) 根植于具有泛型类型参数的方法中, (包含 方法的类上的类型参数或方法) 本身上的一个类型参数,当这些类型参数实例化为引用类型时。

可以使用此重载传递特定的实例化 (例如) 类型的数组,如果有任何) ,则首先 (指定类类型参数,然后指定方法类型参数 ((如果有) )。 运行时准备方法的实例化。 (仅当使用的实例化至少包含一个引用类型参数时才是必需的。) 因此,可以在泛型方法 (或泛型类上的非泛型方法中使用 CER 样式 try 子句) 并且它将可靠地与 实例化或其他值类型的实例化 Int32 一起使用。 若要实例化引用类型(如 String),必须先对 CER 根方法使用显式 PrepareMethod(RuntimeMethodHandle, RuntimeTypeHandle[]) 方法。

适用于