ModuleInitializer Not Being Called

Dec 9, 2008 at 11:44 PM
I'm having an issue where I have 3 modules: a BusinessObjects module, a DAL module, and a Messaging helper module.  Each module is defined as a service and its moduleinitializer does the usual .AddNew stuff.

For some reason when I set a breakpoint on the AddGlobalServices of each, my Messaging module is never being called.  So, when my DAL module does a setter injection for a Messaging object I get a "service x is not valid in this context."

What might cause a module to not have their moduleinitializer called?

Can you control the order of them being called?  Even if it was being called, how does wcsf make sure things are in the right order?  I have a presenter that does setter injection to build a business entity service.  That business entity object does a setter for its dal service.  the dal object in turn is doing a setter on the messaging service.

I double-checked the web.config to make sure all the modules are listed in the compositeweb section and looks to be correct.

Any ideas?

Dec 10, 2008 at 12:33 AM
In testing some more, I find that when I remove the injection of the MessagingService into the DAL service, the message service's moduleinitializer DOES get called.  I test doing setter injection of the message service in a presenter and it works fine.

So, I wonder  what is causing the moduleinitializer to not get called in the scenario above?

Dec 10, 2008 at 2:01 PM


Perhaps, you are having problems in the order in each module is loaded. You can solve this setting dependencies between them.

You can do that, adding in the compositeWeb\modules\module\dependencies node (in the Web.config file) of your module the name of the module that it depends. If the module is a Business Module, you can find the module’s dependencies node in the Web.config file under the module subfolder. If the module is a Foundational Module, you can find the module’s dependencies node in the root Web.config of the Web Project. You may find useful the following example:


<module name="SecondaryModule" assemblyName="SecondaryModule">


 <dependency module="PrincipalModule" />

<dependency module="Shell" />




You can find more information about modules and dependencies between them in the following topics of the WCSF documentation:

·         Modules

·         How to: Deploy Modules

·         Modularity QuickStart


Please, let me know if this helps.


Ezequiel Sculli

Dec 10, 2008 at 3:07 PM
Many thanks!  That was exactly the problem.  I forgot to set up any dependencies between the modules where necessary!

Thx again.