bovender framework
C# framework that implements MVVM and more
Bovender.Unmanaged.DllManager Class Reference

Manages unmanaged DLLs. More...

Inheritance diagram for Bovender.Unmanaged.DllManager:

Public Member Functions

void LoadDll (string dllName)
 Loads the given DLL from the appropriate subdirectory, depending on the current bitness. More...
 
void LoadDll (string dllName, string expectedSha256Hash)
 Loads the given DLL from the appropriate subdirectory if its Sha1 hash matches the provided hash. More...
 
void UnloadDll (string dllName)
 Unloads a previously loaded DLL. More...
 
 DllManager (params string[] loadDlls)
 
void Dispose ()
 

Static Public Member Functions

static bool DllExists (string dllFileName)
 Checks whether a DLL exists in the application directory or in the custom AlternativeDir. More...
 
static string LocateDll (string dllName)
 Attempts to locate a DLL file in the canonical location (subdirectory of the application directory) or, if set, in an alternative location. More...
 

Protected Member Functions

virtual void Dispose (bool calledFromDispose)
 

Properties

static string AlternativeDir [get, set]
 

Detailed Description

Manages unmanaged DLLs.

Unloads any loaded DLLs upon disposal.

Definition at line 31 of file DllManager.cs.

Member Function Documentation

static bool Bovender.Unmanaged.DllManager.DllExists ( string  dllFileName)
inlinestatic

Checks whether a DLL exists in the application directory or in the custom AlternativeDir.

Parameters
dllFileNameDLL file name to check
Returns
True if the file exists at either of the two locations; false if not.

Definition at line 48 of file DllManager.cs.

void Bovender.Unmanaged.DllManager.LoadDll ( string  dllName)
inline

Loads the given DLL from the appropriate subdirectory, depending on the current bitness.

The DLL is expected to reside in a subdirectory of the entry point assembly's directory, in "bin/lib/$(Platform)", where can be "Win32" or "x64", for example. If DllManager.AlternativeDir is set, the subdirectories there will be queried as well.

Exceptions
DllNotFoundExceptionif the file is not found in the path.
DllLoadingFailedExceptionif the file could not be loaded.
Parameters
dllNameName of the DLL to load (without path).

Definition at line 134 of file DllManager.cs.

void Bovender.Unmanaged.DllManager.LoadDll ( string  dllName,
string  expectedSha256Hash 
)
inline

Loads the given DLL from the appropriate subdirectory if its Sha1 hash matches the provided hash.

The DLL is expected to reside in a subdirectory of the entry point assembly's directory, in "bin/lib/$(Platform)", where can be "Win32" or "x64", for example. If DllManager.AlternativeDir is set, the subdirectories there will be queried as well.

Parameters
dllNameName of the DLL to load (without path).
expectedSha256HashExpected Sha1 hash of the DLL.
Exceptions
DllNotFoundExceptionif the file is not found in the path.
DllLoadingFailedExceptionif the file could not be loaded.
DllSha1MismatchExceptionif the file's Sha1 is unexpected.

Definition at line 155 of file DllManager.cs.

static string Bovender.Unmanaged.DllManager.LocateDll ( string  dllName)
inlinestatic

Attempts to locate a DLL file in the canonical location (subdirectory of the application directory) or, if set, in an alternative location.

Parameters
dllNameDLL to search
Returns
Complete path to the DLL file, or String.Empty if the DLL was not found.

Definition at line 61 of file DllManager.cs.

void Bovender.Unmanaged.DllManager.UnloadDll ( string  dllName)
inline

Unloads a previously loaded DLL.

Does nothing if the DLL was not loaded.

Parameters
dllNameName of the DLL to unload.

Definition at line 192 of file DllManager.cs.


The documentation for this class was generated from the following file: