This is just weird. Here's the code :
AppDomain newDomain = AppDomain.CreateDomain("newDomain ", null,
new AppDomainSetup
{
ApplicationBase = @"D:\myDLLFolderFullPath\"
});
Assembly a = newDomain.Load("myAssembly");
This throws the "Could not load file or assembly" error.
I checked my Assembly's dll is located under the specified folder path, and the name of the Assembly is correct.
When I copy myAssembly.dll into the CurrentDomain's main folder, it works !
It behaves as if the ApplicationBase setting for the new AppDomain has absolutely no effect and keep pointing to the Current AppDomain's AppBase.
Any Ideas ?
I am not sure if .NET allows loading assemblies from paths that are not relative to the main executable path.
So, I think that this is not allowed:
D:\myExeFolderFullPath\main.exe
D:\myDLLFolderFullPath\Mydll.dll
...while this should work:
D:\myExeFolderFullPath\main.exe
D:\myExeFolderFullPath\myDLLFolderFullPath\Mydll.dll
Update:
I had a similar problem with paths when working on the mygeneration project. The only way I found to get it running was to reorganize the folder structure I described in this answer.
See msdn for appDomain.load() method: *
This method should be used only to load an assembly into the current application domain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With