Jan 14, 2009 at 12:48 PM
Edited Jan 14, 2009 at 12:58 PM
The default way to set a dependency between modules to make sure a specific module is loaded before another one does using static module loading could be the following one (with your sample module
protected override IModuleCatalog GetModuleCatalog()
var catalog = new ModuleCatalog();
Remember that it is important that modules have no knowledge of each other to maintain the application loosely coupled, and making ModuleA know where ModuleB is deployed
would be against this. Perhaps you could implement this as an assembly reference instead of a Module dependency, by creating separate projects an referencing the one with ModuleB’s functionality from ModuleA but remaining as a single module to your application.
However, if you still want to add new modules without changing the bootstrapper’s GetModuleCatalog() method, and don’t want to expose the dependency between Modules A and B I will explain
how to do this below. You should also be aware that this will create a strong couple of the module to the CAL’s interfaces’ implementations.
To do this you can add the following code in Module A’s Inititialize() method:
ModuleCatalog catalog = this.container.Resolve<IModuleCatalog>() as ModuleCatalog;
if (catalog != null)
catalog.AddModule("ModuleB", typeof(ModuleB).AssemblyQualifiedName, InitializationMode.OnDemand);
IModuleManager moduleManager = this.container.Resolve<IModuleManager>();
if (moduleManager != null)
For more information about module loading you can check:
How to: Load Modules On Demand (documentation)
How to: Statically Load Modules (documentation)
Please let me know if this helps.