Role of Module, ModuleCatalog in Prism v4's new MEF-ized world (for Silverlight)?

Topics: Prism v4 - Silverlight 4
Oct 9, 2010 at 10:32 PM

The StockTrader-RI sample was using a ModuleCatalog and [ModuleExport] in alpha-Drop-8, but no longer is in beta-Drop-9, which makes me wonder what the value of Module and ModuleCatalog are in a MEF-ized world.

The ModularityWithMef and RegionNavigation samples in Drop-9 are MEF-ized, but still use Module and ModuleCatalog. That is apparently only necessary because these Silverlight apps are broken up into multiple XAP files that get downloaded dynamically.

Assuming I'm using MEF and Silverlight, is that multi-XAP case the only place Module makes sense?


Oct 12, 2010 at 8:06 PM


In Prism drop 9, the StockTrader RI does not setup the Module Catalog as in previous versions, since it uses the AggregateCatalog.  

Therefore, modules are intentionally left empty, since views, services and other types are exported using declarative attributes.

But in the MefBootstrapper is still exporting the ModuleCatalog, so you could make of use of this if necessary. For example  the Silverlight ModularityQuickstartWithMEF is using ModuleCatalog as you mentioned. On the other hand, if you need to use View Injection because you need a particular programmatic control, you could also export a module.

Additionally, if you have an scenario where it is necessary to configure your catalog by configuration file, you need to use ConfigurationModuleCatalog. From the QuickstartBootstrapper.cs (code line 121) in the ModularityQuickstartWithMEF:

When using MEF, the existing Prism ModuleCatalog is still the place to configure modules via configuration files.

Hope this helps.

Fernando Antivero


Oct 14, 2010 at 8:45 PM
Edited Oct 14, 2010 at 8:45 PM

Yes, thanks Fernando.