Recently, I hit my head against a brick wall, trying to solve a very similar problem. I have a DLL that I want to load at runtime, and it has its own dependencies. I couldnโt understand all my life why it would load, but when I called the class constructor in the loaded assembly, the error was not raised, and the execution simply stalled, leaving you wondering what was going on.
It turns out that the dependency of the loaded assembly was in a different version of .NET, and there is App.Config in this code to enable mixed-mode assemblies. Therefore, of course, I also had to include this in my code, since I call the assembly, which calls the assembly in another version of .NET.
The error did not appear until I copied the entire dependent DLL into my application during development. Now I can delete them again! In doing so, I get a DLL Loader Lock warning. If I suppress it or ignore it, my code works.
In my case, then the resolution was:
<?xml version="1.0"?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> </configuration>
source share