MEF import not found in Silverlight class library

Topics: Prism v4 - Silverlight 4
Aug 12, 2011 at 8:50 PM
Edited Aug 12, 2011 at 11:04 PM

I am using Prism + MEF in a project with multiple XAP modules.

In my bootstrapper i register a service in the ConfigureContainer method like so: this.Container.ComposeExportedValue<IService>(new MyService());

Importing the service instance works fine in all my viewmodels that are part of a module.

But when I try to import it in a project that is in a separate class library it is not found.

Basically in some other class library, and a control in that class library. The control imports its viewmodel. This works. The viewmodel seems to be able to import some basic classes fine (like the IRegionManager and IModuleCatalog), but cannot satisfy my IService. It is being imported the same way as in other module viewmodels and it works, just not in this class library.

edit: actually it looks like none of the imported instances in the class library are the same. I just tried publishing an event from the imported EventAggregator and it was not caught by the subscriber like it is with other viewmodels in my modules. 

My concrete service is not marked with an [Export()] in this case, but I did try and the class library viewmodel did find it then, but its not the same configured instance I registered in the bootstrapper.

So it seems like this class library is pulling from a different AggregateCatalog or something. Am I composing it wrong? Or leaving some step out?

Aug 15, 2011 at 2:37 PM


It would be helpful if you could provide us with a repro sample application that portrays your problem, so we can help you find the cause and a possible workaround for your issue.


Agustín Rodriguez Adami