Drop 9 - DirectoryModuleCatalog() doesn't work

Topics: Prism v2 - WPF 3.5
Jan 17, 2009 at 4:56 PM
I changed the references in my project to drop 9, and the shell was empty.

I verified: the DirectoryModuleCatalog returns 0 items.

Just come back to Drop 8 dll and everything is ok.

Jan 17, 2009 at 8:56 PM

Are your module setting the StartupLoaded paremter of the ModuleAttribute by any chance?  If you are, anywhere you have StartupLoaded = true (or StartupLoaded = false) can you try setting it to OnDemand=false (or OnDemand=true).
We recently introduced the OnDemand attribute and are moving away from the StartupLoaded attribute.  StartupLoaded should still work, but perhaps we missed something.


Jan 18, 2009 at 1:13 AM
You were right:  I change StartupLoaded=true for OnDemand=false and it's working.  StartapLoaded doesn' work.

By the way,  can you please show me where and how I load the modules I need when they are marked as OnDemand=true?

Thanks in advance,

Jan 19, 2009 at 12:49 PM

Hi Marcos,


Perhaps you might find useful the following topic in the documentation and quickstarts to load modules on demand. These are from the latest Prism-v2 drop:

·         How to: Load Modules On Demand (documentation topic).

·         RemoteModuleLoading quickstart, in the $Drop9$\Quickstarts\Modularity\RemoteModuleLoading folder, which uses the ModuleCatalog.xaml file to define how to load modules (DefaultViewY has the code to load the module on demand).

·         StaticModuleLoading quickstart, in the $Drop9$\Quickstarts\Modularity\StaticModuleLoading folder, which defines how to load modules via code (DefaultViewB has the code to load the module on demand).


Please let me know if this helps.


Damian Schenkelman


Jan 20, 2009 at 4:30 PM

Hi Damian,

Thanks for your answer.  I still can't found where to put the code in the boostrapper with DirectoryModuleCatalog.  Here is my bootstrapper:
public class Bootstrapper : UnityBootstrapper
        protected override IModuleCatalog GetModuleCatalog()
            return new DirectoryModuleCatalog() { ModulePath = @".\Modules" };

        protected override void ConfigureContainer()
            Container.RegisterType<IShell, Shell>(new ContainerControlledLifetimeManager());

        protected override DependencyObject CreateShell()
            ShellPresenter presenter = Container.Resolve<ShellPresenter>();
            IShell view = presenter.View;
            return view as DependencyObject;


Where I load de modules I need ?  Thanks in advance;


Jan 20, 2009 at 6:26 PM
Edited Jan 20, 2009 at 6:27 PM

Hi Marcos,


To load a module on demand using the DirectoryModuleCatalog class you do not need to add any extra code in the Boostrapper class (you need to be sure that all modules assemblies are located in the $SolutionPath$\bin\Debug\Modules folder).


Generally, the code that loads a module on demand is executed in response to an event, like the user clicking in a button.

You need to add the following code to the class in charge of handling the event raised to load the module:

1.       Get a reference to the Module Manager.


private readonly IModuleManager moduleManager;


// Constructor.

public MyClass(IModuleManager moduleManager)


this.moduleManager = moduleManager;



2.       When you want to load a module, execute the LoadModule method of the Module Manager passing the module name (which is set through the ModuleName property of the ModuleAttribute) as a parameter.


// The user clicks in a button.

private void OnLoadModuleCClick(object sender, RoutedEventArgs e)





For more information related to this you can check the following:

·         The DirectoryLookupModularity Quickstart located in the $Prism v2 – Drop 9 Path$\Quickstarts\Modularity\DirectoryLookupModularity folder.

·         The Development Activities  -> How to: Load Modules On Demand topic in the documentation.


Please let me know if this helps.


Mariano Converti


Jan 20, 2009 at 6:55 PM
Hi Mariano,

Thanks for the help.  My problem is to load the modules I need in the bootstrapper.  That let me to reuse the shell with different subsystems, without having different directories with lot of common components.

How can I get the reference to the moduleManager in the bootstrapper?