Dynamic loading is working fine, except that the ILMerged executable

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 have an ILMerge application with a different DLL.

So this script works fine:

  • Myapp.exe
  • Myappppponent.dll
  • Plugin.dll

As soon as I ILMerge MyApp.exe and MyAppComponent.dll as a result:

  • Myapp.exe
  • Plugin.dll

The call Reflection.Assembly.LoadFrom("Plugin.dll")seems to be loaded successfully, however as soon as I try to do something with it, for example:

foreach ( typeAsm in Reflection.Assembly.LoadFrom("Plugin.dll")) 

I get the exception "I cannot load one or more of the requested types. Extract the loader exception property for more information."

A depressing thing: I can't debug it, because debugging a pre-merge works great!

reference

+5
1

, Plugin.dll MyApp.exe MyAppComponent.dll, (MyApp.exe) (MyApp.dll) ILMerging.

, ILMerge .

+2

All Articles