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 assemb开发者_StackOverflow中文版ly used in the plugin?
Thanks, PaulH
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.
精彩评论