NativeLibrary.TryLoad 方法

定义

重载

TryLoad(String, IntPtr)

提供一个简单 API,用于加载本机库并返回一个指示操作是否成功的值。

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

提供一个高级 API,用于加载本机库并返回一个指示操作是否成功的值。

TryLoad(String, IntPtr)

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

提供一个简单 API,用于加载本机库并返回一个指示操作是否成功的值。

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

参数

libraryPath
String

要加载的本机库的名称。

handle
IntPtr

nativeint

当方法返回时,已加载的本机库的 OS 句柄。

返回

true 如果已成功加载本机库,则为 ;否则为 false

例外

libraryPathnull

适用于

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

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

提供一个高级 API,用于加载本机库并返回一个指示操作是否成功的值。

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

参数

libraryName
String

要加载的本机库的名称。

assembly
Assembly

用于加载本机库的程序集。

searchPath
Nullable<DllImportSearchPath>

搜索路径。

handle
IntPtr

nativeint

当方法返回时,已加载的本机库的 OS 句柄。

返回

true 如果已成功加载本机库,则为 ;否则为 false

例外

libraryPathassemblynull

assembly 不是 RuntimeAssembly

适用于