This is strange.
I have a windows application that dynamically loads DLLs using Reflection.Assembly.LoadFrom(dll_file_name_here)
.
It works as expected, until I ILMerge the application with another DLL.
So this scenario works fine:
Once I ILMerge MyApp.exe and MyAppComponent.dll resulting in:
Calling Reflection.Assembly.LoadFrom("Plugin.dll")
seems to load successfully, however once I try to do anything with it eg:
foreach ( typeAsm in Reflection.Assembly.LoadFrom("Plugin.dll"))
I get an exception "unable to load one or more of the requested types. retrieve the loader exceptions property for more informtion".
The frustrating thing is I can't really debug it, because debugging pre merging works perfectly!
Help?
My guess is that Plugin.dll references MyApp.exe or MyAppComponent.dll, which are not binary compatible (MyApp.exe) or not there at all (MyApp.dll) after ILMerging.
If that is the case, you shouldn't ILMerge them.
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