How to populate catalog from xaml file

Topics: Prism v4 - Silverlight 4
Aug 12, 2010 at 6:39 AM


I would like to populate my catalog from a xaml file. Unfortunatly nothing is display in the shell.

When i populate in code, everything work fine.

I add a silverlight control file and i delete the code-behind.

I copy the ModuleA.xap in the ClientBin directory.



      ModuleType="ModuleA.ModuleA, ModuleA, Version="
MEFBootstrapper :
  protected override IModuleCatalog CreateModuleCatalog()
            return Modularity.ModuleCatalog.CreateFromXaml(new Uri("/HDMSApplication;component/ModuleCatalog.xaml", UriKind.Relative));
Aug 13, 2010 at 7:51 PM


I do not know your exact scenario, but it seems that the problem for initializing your ModuleA resides in the ModuleType specified. You may need to specify a more fully-qualified type name. That said, your ModuleType could look like the following:

<Modularity:ModuleInfo Ref="ModuleA.xap" ModuleName="ModuleA"
ModuleType="ModuleA.ModuleA, ModuleA, Version=, Culture=neutral, PublicKeyToken=null"
InitializationMode="WhenAvailable" />

Additionally it is necessary to decorate your module class initializer as is shown below:

[ModuleExport(typeof(ModuleA))] public class ModuleA : IModule

For more information on this topic you could take a look at the MEF Modularity Quickstart (download it here). Please note that this Quickstart contains a log, which shows in run-time the state when loading its modules. Therefore, it might be useful for playing with module loading.

Please let me know if this helps.

Fernando Antivero



Aug 13, 2010 at 8:26 PM

Also, make sure that the references to the Prism libraries in your module projects have the "Copy Local" flag set to false.  Otherwise, due to how MEF loads XAPs, the core Prism libraries get loaded twice, the imports are done twice, and you end up with MEF throwing a number of exceptions.