I have a WCF plugin service that loads plugins via MEF and runs them.
Each plugin is a directory with multiple dll's that implements a specific interface.
I load all the plugins in the same AppDomain using MEF (DirectoryCatalog
) and run them in a generic way (using reflection).
Now lets assume I have two plugins with dll dependencies:
Plugin1
----> Entities 1.0.0.1
Plugin2
----> Entities 1.0.0.2
I've added some new entities in 1.0.0.2.
When I run the plugin's I get a sporadic error that the new entities doesn't exist in the dll.
I guess that the error occurs since I'm running the code in the same AppDomain and the first Entities.dll
that loads is the one that will serve all my plugins.
So, how can I run each plugin with isolation, without creating a new appdomain?
Is there any way I can tell MEF to load all plugin dependencies somehow?
I've read about a couple of solutions on the web:
Create a new appdomain for each plugin - I don't want to go there.
Use the
<dependentAssembly>
- This didn't work when I first tried it and I don't want my plugin server to get updated on each assembly dependency version change. Plus, I want to be able to run plugins with different assembly versions.Sign the assemblies with a snk - I didn't try this yet and I'm not sure this solution will work. How will the framework know that he needs to load a different assembly? How is this different from assemblies with different versions? Will I need to configure my service somehow in order to make this work?
Does anybody have any better idea for me? What's the recommended way to run isolated plugins?