DllImportResolver Delegate

Definition

Provides a delegate used to resolve native libraries via callback.

public delegate IntPtr DllImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath);

Parameters

libraryName
String

The native library to resolve.

assembly
Assembly

The assembly requesting the resolution.

searchPath
Nullable<DllImportSearchPath>

The DefaultDllImportSearchPathsAttribute on the PInvoke, if any. Otherwise, the DefaultDllImportSearchPathsAttribute on the assembly, if any. Otherwise null.

Return Value

IntPtr

The handle for the loaded native library on success, or Zero on failure.

Remarks

The runtime does not do any lifetime management around the handle returned by a DllImportResolver. It is left to the implementation and consuming code to keep the library loaded for as long as necessary and free it if/when desired.

Extension Methods

GetMethodInfo(Delegate)

Gets an object that represents the method represented by the specified delegate.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9