Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Late Loading a .net plugin dll

I have a C# .Net 2.0CF application where I would like to load a .NET 'plug-in' DLL at runtime.

As I understand it, I should be able to use the System.Reflection.Assembly.LoadFrom() to load the DLL to an Assembly. Then use Assembly.GetTypes() to get the list of types within the plugin to match them to my expected interfaces.

The problem is that when I call GetTypes(), I get a System.TypeLoadException(). Based on the exception message, I assume this is because this particular plugin references some other assembly that this program knows nothing about. But, that's part of the point of it being a plugin! I don't want my application to have to know anything about these other assemblies.

How can I load this plug-in DLL without having my application reference every assembly used in the plugin?

Thanks, PaulH

like image 283
PaulH Avatar asked Nov 19 '25 00:11

PaulH


1 Answers

The situation is not that your app should reference every assembly that a plug-in uses. The plug-in references another DLL, not your app, and the plug-in should be "installed" (maybe simply put in a directory) along with everything it needs. This is unavoidable.

like image 58
Timores Avatar answered Nov 20 '25 13:11

Timores



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!