ModuleInfo.ModuleName with MefBootstrapper

Topics: Prism v4 - Silverlight 4
Mar 29, 2011 at 5:40 PM


Standard Prism application (Shell + ModuleA) with MefBootstrapper.

ModuleCatalog.xaml describes ModuleInfo like this:

        ModuleType="ModuleA.ModuleDefinitions.ModuleA, ModuleA, Version="

 [ModuleExport(typeof(ModuleA))] public class ModuleA : IModule
        private readonly IRegionManager _RegionManager;
        private IModuleCatalog _Container;

        public ModuleA(IModuleCatalog container, IRegionManager regionManager)
            this._Container = container;
            this._RegionManager = regionManager;

        public void Initialize()
            _RegionManager.RegisterViewWithRegion("ModuleARegion", typeof(ModuleAView));


ModuleA is loaded OnDemand from Shell using  ModuleManager.LoadModule("ModuleA");.... Everything is nice...

Now, rename ModuleName in ModuleCatalog.xaml to something else, for example like this:

ModuleType="ModuleA.ModuleDefinitions.ModuleA, ModuleA, Version=" > 

and load moduleAAAAA again in code, or just set InitializationMode = WhenAvailabe... Boom Crash...Exception: 

Unable to locate the module with type 'ModuleA.ModuleDefinitions.ModuleA, ModuleA, Version=' among the exported modules. Make sure the module name in the module catalog matches that specified on ModuleExportAttribute for the module type.
Only name of the module was changed in config...I found that ModuleName should match  [ModuleExport(typeof(ModuleA))]  in ModuleA class....
With Unity ModuleName can have any value - everything works fine....
BUG -((
Mar 29, 2011 at 6:28 PM


The behavior you're mentioning is by design; the MefModuleManager and MefModuleInitializer use the ModuleExport attribute to identify the modules that will be loaded and initialized using MEF. Therefore, the name in the ModuleExport attribute must match the name given to the module in the module catalog.

If you consider this behavior is unappropriate for you, you could create a work item in the Issue Tracker and explain your reasons, for the matter to be reconsidered on future versions of Prism.

I hope you find this helpful.

Guido Leandro Maliandi

Mar 29, 2011 at 6:39 PM


I think that ModuleInfo.ModuleName should not have any relation to Type of Module ...At least in prism.

I think it will make sense to create work item...


Mar 29, 2011 at 6:54 PM
Edited Mar 29, 2011 at 6:54 PM

Take into account that the ModuleName must match the name provided in the ModuleExport, but not necessarily the Type.

If you don't provide a name in the ModuleExport attribute, the ModuleType will be used as its name.

You could try setting the ModuleExport attribute like this:




I hope you find this helpful.

Guido Leandro Maliandi

Mar 29, 2011 at 7:38 PM

thats right. This is what i faced in my code.

Idea is to name module in external xaml file, not in module export attribute... same as unity does