Set unmanaged DLL load directory
I need to load a library from a specific directory. Instead of using specific functions like LoadLibrary (Windows) or dlopen (Linux) I would like to temporary add this folder to the search path.
So I have:
public static void AddOrUpdateDllPath(string dllDirectory)
{
dllDirectory = dllDirectory.NormalizePathDelimiters("");
var path = "";
switch (RunningPlatform)
{
case OperatingSystem.Windows:
path = "PATH";
Environment.SetEnvironmentVariable(path, Environment.GetEnvironmentVariable(path) + ";" + dllDirectory);
break;
case OperatingSystem.MacOS:
path = "LD_LIBRARY_PATH";
throw new NotImplementedException("How to change " + path);
break;
case OperatingSystem.Linux:
path = "DYLD_FRAMEWORK_PATH";
throw new NotImplementedException("How to change " + path);
break;
}
}
I dont not know how to add the path variable for Linux and MaxOS ?
链接地址: http://www.djcxy.com/p/44590.html上一篇: linux.so.2与单声道的DllImport?
下一篇: 设置非托管DLL加载目录