Question

I'm developing an application with plugins. I have a separate API assembly with all the API interfaces.

The main application dynamically loads the plugins from dlls:

object pi = Assembly.LoadFrom(plugin.AssemblyPath)
              .CreateInstance(plugin.ClassName);

and then i'm casting it to the actual plugin type:

IPlugin pluginInstance = (IPlugin)pi;

All of this is working fine when none of the assemblies are signed. As soon as i sign them (main app, API assemply and the plugin assemply) it fails to cast, throwing:

Unable to cast object of type '.MyPlugin' to type '.IPlugin'.

Any suggestions?

Was it helpful?

Solution

Got it! The issue was that i had two copies on API.dll - one in the application folder, and another in the Plugins subfolder. When I've deleted Plugins\API.dll it has started working fine.

(It has worked fine with two copies in unsigned mode though)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top