NativeLibrary.Load 方法

定義

多載

Load(String)

提供簡單的 API,以載入包裝作業系統載入器並使用預設旗標的原生程式庫。

Load(String, Assembly, Nullable<DllImportSearchPath>)

提供高階 API 以載入原生程式庫。

Load(String)

來源:
NativeLibrary.cs
來源:
NativeLibrary.cs
來源:
NativeLibrary.cs

提供簡單的 API,以載入包裝作業系統載入器並使用預設旗標的原生程式庫。

public:
 static IntPtr Load(System::String ^ libraryPath);
public static IntPtr Load (string libraryPath);
static member Load : string -> nativeint
Public Shared Function Load (libraryPath As String) As IntPtr

參數

libraryPath
String

要載入的原生程式庫名稱。

傳回

IntPtr

nativeint

已載入的原生程式庫作業系統控點。

例外狀況

libraryPathnull

找不到程式庫。

程式庫無效。

適用於

Load(String, Assembly, Nullable<DllImportSearchPath>)

來源:
NativeLibrary.cs
來源:
NativeLibrary.cs
來源:
NativeLibrary.cs

提供高階 API 以載入原生程式庫。

public:
 static IntPtr Load(System::String ^ libraryName, System::Reflection::Assembly ^ assembly, Nullable<System::Runtime::InteropServices::DllImportSearchPath> searchPath);
public static IntPtr Load (string libraryName, System.Reflection.Assembly assembly, System.Runtime.InteropServices.DllImportSearchPath? searchPath);
static member Load : string * System.Reflection.Assembly * Nullable<System.Runtime.InteropServices.DllImportSearchPath> -> nativeint
Public Shared Function Load (libraryName As String, assembly As Assembly, searchPath As Nullable(Of DllImportSearchPath)) As IntPtr

參數

libraryName
String

要載入的原生程式庫名稱。

assembly
Assembly

載入原生程式庫的組件。

searchPath
Nullable<DllImportSearchPath>

搜尋路徑。

傳回

IntPtr

nativeint

已載入的程式庫作業系統控點。

例外狀況

libraryNameassemblynull

assembly 不是 RuntimeAssembly

找不到程式庫。

程式庫無效。

備註

指定連結庫名稱時,此方法會根據呼叫元件的運行時間組態、輸入參數和屬性來搜尋特定路徑。 searchPath如果參數為非 Null,則會使用此列舉中的旗標。 否則,會使用呼叫元件上所指定的 DefaultDllImportSearchPathsAttribute 旗標,如果有的話。 這個方法不會叫用使用 SetDllImportResolver(Assembly, DllImportResolver) 方法註冊的解析程式。 從 .NET 5 開始,這個方法會叫 AssemblyLoadContext.LoadUnmanagedDll 用 方法和 AssemblyLoadContext.ResolvingUnmanagedDll 事件。

適用於