bsayegh
bsayegh

Reputation: 1000

Error being thrown when using multiple MEFS plugins that reference the same assembly

I have a project that uses MEFs and allows developers to add different plugins. Many of these plugins have similar methods and need to do similar things, so I created a base class in another project called PluginBase, which they inherit from. All of the plugins build to the same directory (where MEFs loads its catalog), and the PluginBase dll is also built to that directory.

If I only have 1 plugin in that directory, it works fine. If I have multiple that reference PluginBase, I get the error:

{"Could not load type 'BCDTravel.API.PluginBase.PluginBase' from assembly 'TEST.API.PluginBase, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.":"TEST.API.PluginBase.PluginBase"}

That is the only message that I receive.

I am guessing if I added PluginBase to the GAC it would work, but I don't really understand what the problem is. Is it a problem with the assembly being loaded multiple times?

Thanks!

Upvotes: 0

Views: 89

Answers (1)

Ilija Dimov
Ilija Dimov

Reputation: 5299

The problem is that you are loading the same assembly multiple times. Put the assembly that your PluginBase class belongs to in the bin folder of your application and add it to the MEF Catalog from there. Load only plugin specific assemblies from Plugins folder.

Upvotes: 1

Related Questions