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 樣子 try 句, (泛型方法或泛型類別上的非泛型方法) ,而且它會可靠地使用 或其他實值型別的 Int32 具現化。 若要具現化這類 String的參考型別,您必須先在 CER 根方法上使用明確的 PrepareMethod(RuntimeMethodHandle, RuntimeTypeHandle[]) 方法。

適用於