Mefbootstrapper.cs questions

Topics: Prism v4 - WPF 4
Jun 20, 2010 at 7:40 PM

I'm rather confused with the code in the MefBootstrapper below:

this.Logger.Log("Creating module catalog.", Category.Debug, Priority.Low);

this.Logger.Log("Configuring module catalog.", Category.Debug, Priority.Low);

this.Logger.Log("Creating catalog for MEF", Category.Debug, Priority.Low);

this.Logger.Log("Configuring catalog for MEF", Category.Debug, Priority.Low)

It looks to me like the first call is creating and configuring a catalog based on a configuration file and the second a standard aggregate catalog. If that's the case then why the confusing names? Are these both not just different types of "module catalogs"? Can I not add module information to the catalog the aggregate way?

I took out the calls to the Module catalog and also the line further down "this.Container.ComposeExportedValue<IModuleCatalog>(this.ModuleCatalog);"  Now the code seems to get upset as there is no IModuleCatalog.

So .. maybe I'm completely messed up but how can I use the MefBootstrapper when I don't want to use a configuration file to store part of my module information?


Oct 15, 2010 at 9:35 PM
Edited Oct 15, 2010 at 9:35 PM

Hi Richard,

Sorry for the delayed response. When using MEF, a ConfigurationModuleCatalog must be created to be able to determine which modules should be loaded through configuration files. This is shown in the following code from the Bootstrapper of the Modularity Quickstart with MEF (Prism v4 Drop 2):

protected override void CreateModuleCatalog()
    // Module C is referenced by this project and in the configuration
    // Module E only referenced in the configuration
    this.ModuleCatalog = new ConfigurationModuleCatalog();

As you can see in Prism v4 Drop 10, the CreateModuleCatalog method (in the QuickStartBootstrapper of the Modularity Quickstart with MEF) has a comment that says “when using MEF, the existing Prism ModuleCatalog is still the place to configure modules via configuration files”. This implies that it is possible to achieve Prism’s module loading approaches with MEF through the use of MEF Catalogs except for configuring modules through configuration files.

If you don’t need to use a configuration file to determine which modules should be loaded, there is no need to create the ConfigurationModuleCatalog.

Fernando Antivero