I am new in dotnet.I have a dotnet dll that loads a c
dll by using DllImport
. I want to place all the dlls in a folder which is diffrent from the l
I'd suggest adding the directory path to PATH env variable in runtime, using the following code:
var dllDirectory = @"C:/some/path";
Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + dllDirectory);
That way, the change is only affecting the running process and is discarded when it exits.
Take a look at the documentation for LoadFrom and you'll find that it says: If a native image exists for assemblyFile, it is not used. The assembly cannot be loaded as domain neutral.
I believe you're going to need to add the DLL directory to the EXE's path.