Edit

Share via


NativeLibrary.TryLoad Method

Definition

Overloads

TryLoad(String, IntPtr)

Provides a simple API for loading a native library and returns a value that indicates whether the operation succeeded.

TryLoad(String, Assembly, Nullable<DllImportSearchPath>, IntPtr)

Provides a high-level API that loads a native library and returns a value that indicates whether the operation succeeded.

TryLoad(String, IntPtr)

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

Provides a simple API for loading a native library and returns a value that indicates whether the operation succeeded.

public:
 static bool TryLoad(System::String ^ libraryPath, [Runtime::InteropServices::Out] IntPtr % handle);
public static bool TryLoad (string libraryPath, out IntPtr handle);
static member TryLoad : string * nativeint -> bool
Public Shared Function TryLoad (libraryPath As String, ByRef handle As IntPtr) As Boolean

Parameters

libraryPath
String

The name of the native library to be loaded.

handle
IntPtr

nativeint

When the method returns, the OS handle of the loaded native library.

Returns

true if the native library was loaded successfully; otherwise, false.

Exceptions

libraryPath is null.

Applies to

TryLoad(String, Assembly, Nullable<DllImportSearchPath>, IntPtr)

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

Provides a high-level API that loads a native library and returns a value that indicates whether the operation succeeded.

public:
 static bool TryLoad(System::String ^ libraryName, System::Reflection::Assembly ^ assembly, Nullable<System::Runtime::InteropServices::DllImportSearchPath> searchPath, [Runtime::InteropServices::Out] IntPtr % handle);
public static bool TryLoad (string libraryName, System.Reflection.Assembly assembly, System.Runtime.InteropServices.DllImportSearchPath? searchPath, out IntPtr handle);
static member TryLoad : string * System.Reflection.Assembly * Nullable<System.Runtime.InteropServices.DllImportSearchPath> * nativeint -> bool
Public Shared Function TryLoad (libraryName As String, assembly As Assembly, searchPath As Nullable(Of DllImportSearchPath), ByRef handle As IntPtr) As Boolean

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.

handle
IntPtr

nativeint

When the method returns, the OS handle of the loaded native library.

Returns

true if the native library was loaded successfully; otherwise, false.

Exceptions

libraryPath or assembly is null.

assembly is not a RuntimeAssembly.

Applies to