Редагувати

Поділитися через


NativeLibrary.Load Method

Definition

Overloads

Load(String)

Provides a simple API for loading a native library that wraps the OS loader and uses default flags.

Load(String, Assembly, Nullable<DllImportSearchPath>)

Provides a high-level API for loading a native library.

Load(String)

Source:
NativeLibrary.cs
Source:
NativeLibrary.cs
Source:
NativeLibrary.cs

Provides a simple API for loading a native library that wraps the OS loader and uses default flags.

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

Parameters

libraryPath
String

The name of the native library to be loaded.

Returns

IntPtr

nativeint

The OS handle for the loaded native library.

Exceptions

libraryPath is null.

The library can't be found.

The library is not valid.

Applies to

Load(String, Assembly, Nullable<DllImportSearchPath>)

Source:
NativeLibrary.cs
Source:
NativeLibrary.cs
Source:
NativeLibrary.cs

Provides a high-level API for loading a native library.

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

Parameters

libraryName
String

The name of the native library to be loaded.

assembly
Assembly

The assembly loading the native library.

searchPath
Nullable<DllImportSearchPath>

The search path.

Returns

IntPtr

nativeint

The OS handle for the loaded library.

Exceptions

libraryName or assembly is null.

assembly is not a RuntimeAssembly.

The library can't be found.

The library is not valid.

Remarks

Given a library name, this method searches specific paths based on the runtime configuration, input parameters, and attributes of the calling assembly. If the searchPath parameter is non-null, the flags in this enumeration are used. Otherwise, the flags specified by the DefaultDllImportSearchPathsAttribute on the calling assembly, if any are present, are used. This method does not invoke the resolver registered using SetDllImportResolver(Assembly, DllImportResolver) method. Starting with .NET 5, this method does invoke the AssemblyLoadContext.LoadUnmanagedDll method and the AssemblyLoadContext.ResolvingUnmanagedDll event.

Applies to