This project is read-only.

MEF/Unity integration point in Bootstrapper?

Mar 23, 2010 at 10:23 PM

What is a good place to insert the MEF integration code in a typical PRISM app with it's own bootstrapper?

The following use in the ComposeMEF method seems reasonable to me, but it raises a NotSupportException with the message "The invoked member is not supported in a dynamic assembly" when the bootstrapper Run method is called.

Thanks for any guidance.

internal class Bootstrapper : UnityBootstrapper
protected override DependencyObject CreateShell()
var view = Container.Resolve<ShellView>();
return view;

protected override void ConfigureContainer()

ComposeMef(); // Start PRISM/MEF integration - is this appropriate usage?

private void ComposeMef()
// Setup
var unityContainer = new UnityContainer();
var aggregateCatalog = new AggregateCatalog();

// Register catalog

protected override IModuleCatalog GetModuleCatalog()
return new DirectoryModuleCatalog() { ModulePath = @".\Modules" };


Mar 24, 2010 at 1:16 PM

The most common way is to override CreateContainer method:

protected virtual IUnityContainer CreateContainer()
    var container = new UnityContainer();
    container.RegisterCatalog(some catalog);

    return container;

Your code has one mistake. You create new Unity container within a ComposeMef method which is invoked in the ConfigureContainer method. This is effortless since when the ConfigureContainer method is launched, the container is already created for you. You can add a return statement for ComposeMef method and invoke it within CreateContainer method.

Hope this helps.

Piotr Włodek