This project is read-only.

How to make OnDemand Prism modules work?

Apr 27, 2010 at 5:30 PM

I'm trying to load Prism modules OnDemand, but am missing something, because the MEF-exported thingies in the module seemingly are not visible to Prism.

In UnityExportProvider.GetExportsCore(...), I'm getting an ImportCardinalityMismatchException:

"No valid exports were found that match the constraint '((exportDefinition.ContractName == "UnityIntegration01.Module01.IMyOtherStuff") "... etc.

(I have set up my bootstrapper as described in - and added a module catalog).

Example module:

using System;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Composite.Regions;
using Microsoft.Practices.Composite.Modularity;
using System.ComponentModel.Composition;

namespace UnityIntegration01.Module01
    public class MyModule : IModule
        public IMyOtherStuff Stuff { get; set; }

        #region IModule Members

        public void Initialize()
            // NOP.   


    public interface IMyOtherStuff
    { }

    public class MyOtherStuff : IMyOtherStuff
    { }

Any clues?



Apr 27, 2010 at 7:20 PM

Temporary workaround: explicitly put the module's assembly into MEF's scope.

public MyModule(IUnityContainer container)
    var bootstrapper = container.Resolve<IBootstrapper>();
    var cat = new AssemblyCatalog(typeof(MyModule).Assembly);


Can this be automated somehow? Can the MEF-contrib code be made to add the newly loaded assemblies automatically?