Problems loading ModuleCatalog from XAML

Topics: Prism v2 - Silverlight 4
Jul 29, 2010 at 4:38 PM
Edited Jul 29, 2010 at 5:46 PM

Hi there,

first of all, thanks for this great piece of work even if it's very complex for a beginner.

I've just started to play around with the quickstarts and experience several problems with the modularity samples. For some reason i'm not able to add own modules to either RemoteModularityQuickstart or DefiningModulesInCodeQuickStart (my teammate tried different sample but with no success too).

Here is, what i've done with RemoteModularityQucikStart:

I made a copy of ModuleX and renamed everything to ModuleA, added a new ModuleInfoGroup to ModuleCatalog.xaml (just copied / renamed ModuleX. I also tried Module without info group like ModuleZ, same bad result).

Then Added a button to DefaultViewY and a correspondig  event-handler to load ModuleA(again, same code as used for ModuleX). Everything compiles fine so far and i can load ModuleX but not the new ModuleA:(


I then used debugger to look whats happening and some strange behaviour appeared to me. The problem takes place in public virtual IEnumerable<ModuleInfo> CompleteListWithDependencies(IEnumerable<ModuleInfo> modules) of ModuleCatalog.cs.

At the end of this function there are these 2 code lines

IEnumerable<ModuleInfo> sortedList = this.Sort(completeList);  

return sortedList;

completeList contains one entry for ModuleA, looks good too me so far. But after this.sort(...)    sortedList is empty(null to be correct).

So i changed code to return completeList; and ModuleA appeared:)  But after that, ModuleX (which has no code changes done by me at all) from the sample does not work anymore.

Again i used debugger, and navigated through the code, and i saw that modulemanager thinks ModuleX has 2 dependencies (ModuleY and ModuleW). But i can't see these dependencies from ModuleCatalog.xaml and for some reason needs a sortedList (mabe anyone can tell me whats the reason for sorting). So changing code back to what it was, helps for ModuleX, but then ModuleA does not work. So where i'm wrong?

Thanks for your help, Joachim

Jul 29, 2010 at 9:39 PM

Hi Joachim,

Based on our understanding, you need to extend the Modularity Quickstart for adding a new module. Although you copied an existent module, I though that we could review the requirements in order to achieve this scenario (some of the following steps was taken from this and this documentation sections on MSDN):

  1. It is necessary to prepare a module (project) for Remote Downloading. So, delete the App/Page xaml files and in the Silverlight tab of your module (it must be a SL app), select (not set) in the Startup object drop down list.
  2. Next, the ModulesCatalog.xaml should be updated  by adding a new ModuleInfo element inside the ModuleCatalog tag. The config element should be similar to the following:
    • <Modularity:ModuleInfo Ref="ModuleA.xap" ModuleName="ModuleA" ModuleType="ModuleA.ModuleA, ModuleA, Version=" InitializationMode="OnDemand"/>
  3. In the handler method of the button click event, you could use the following code line for loading your module:
    • this.moduleManager.LoadModule("ModuleA");
  4. You must update the Assembly name and Xap file name from ModuleX to ModuleA in the properties page of the ModuleA.Silverlight project.
  5. Finally, and one of the most important parts, add a reference to your ModuleA.xap file in the Silverlight Application tab from the properties page of the RemoteModuleLoading.Silverlight.Web project.

Please let me know if this helps.

Fernando Antivero

Jul 30, 2010 at 8:17 AM
Edited Jul 30, 2010 at 1:43 PM

Hi Fernando,

thanks for your quick answer. Thats exactly what i did when adding ModuleA. And as i wrote, in some conditions (if i patch Modularity)  ModuleA loads.

Next I will debug the stock sample and look how the module catalog loads there. I can't see any big mistake so far that could cause what i've seen.


*Update* I did everything from scatch and now it's working. Thx for your support!