RuntimeHelpers.PrepareMethod 方法

定義

準備要加入至限制的執行區域 (CER) 的方法。

多載

PrepareMethod(RuntimeMethodHandle)

準備要加入至限制的執行區域 (CER) 的方法。

PrepareMethod(RuntimeMethodHandle, RuntimeTypeHandle[])

使用指定的執行個體化 (Instantiation) 準備要加入至限制的執行區域 (CER) 的方法。

PrepareMethod(RuntimeMethodHandle)

來源:
RuntimeHelpers.CoreCLR.cs
來源:
RuntimeHelpers.CoreCLR.cs
來源:
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 編譯階段,Common Language Runtime 通常沒有足夠的虛擬呼叫目標相關資訊。 因此,執行時間一開始不會準備呼叫圖形的該區段。 如果使用 CER 的程式碼具有足夠的知識,可在實際輸入 CER 之前的任何時間點判斷目標,它可以呼叫 PrepareMethod(RuntimeMethodHandle) 以針對指定為引數之方法的 CER 執行一般相同的執行時間準備。

適用於

PrepareMethod(RuntimeMethodHandle, RuntimeTypeHandle[])

來源:
RuntimeHelpers.CoreCLR.cs
來源:
RuntimeHelpers.CoreCLR.cs
來源:
RuntimeHelpers.CoreCLR.cs

使用指定的執行個體化 (Instantiation) 準備要加入至限制的執行區域 (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[]) 泛型支援。 Common Language Runtime 無法準備限制的執列區域, (CER) 根目錄的方法中具有泛型型別參數的方法, (類別上的類型參數,或是當這些類型參數具現化為參考型別時,在方法本身上) 。

您可以使用這個多載來傳遞特定的具現化 (,例如類型陣列) ,如果有任何) ,則先指定類別類型參數 (,後面接著方法類型參數, (如果有任何) 。 執行時間會準備方法的具現化。 (只有在您使用的具現化至少包含一個參考型別參數。) 因此,您可以在泛型方法中使用 CER 樣式 try 子句, (泛型方法或泛型類別上的非泛型方法) ,而且它會可靠地搭配具現化 Int32 或其他實值型別使用。 若要具現化例如 的 String 參考型別,您必須先在 CER 根方法上使用明確的 PrepareMethod(RuntimeMethodHandle, RuntimeTypeHandle[]) 方法。

適用於