Alright,
I have a strange one here.
We currently have a tools application that allows us to create plugins, which are just DLLs with usercontrols, that I just load using Assembly.Load and create new instance, add to panel to use.
However a plugin could have 3rd party dlls included.
How can I handle this?
I’ve tried zipping up the plugin and reading the assembly via byte[], but I get an error when trying to load, missing dependant dll, so I went even farther, added dependant dlls into zip and read them, same error..
Perhaps I can create a folder with plugin name with dependant dlls?
I recently had a project with exactly the same problem. Here is how did I solve it:
– create a separate directory for each module (plugin), inside I put main module.dll library and directory lib, where I put all the module-dependent libraries.
– in main Form_Load event put
where
LoadModuleResolveEventHandleris:It makes the application to look in pluginDirectory (where the plugin module is) /lib subdirectory, for a referenced .dll, and return it if found. I did similar in plugin’s code, maybe you don’t have to… That’s it.
Other possibility is to add to the project new item: Application Configuration File, and put the code below:
It creates application_name.exe.config file which must be deploy with main form executable and indicates addicional directories where to look for assembly resolving.
You can tray any of this solutions and see how they work.
Best regards,
mj82