Module Loading Problem

Topics: Prism v2 - WPF 3.5
Jul 7, 2009 at 3:27 AM


private void EnsureModulesDiscovered()
            ModulesConfigurationSection section = this.Store.RetrieveModuleConfigurationSection();


I'm trying to load modules from the configuration file, but it seems that the app is not finding/recognizing the module information in App.config

The following method in ConfigurationModuleCatalog is returning a null value for 'section' when I would be expecting the object to be filled out with the configuration info.  

private void EnsureModulesDiscovered()


            ModulesConfigurationSection section = this.Store.RetrieveModuleConfigurationSection();



Does anyone have an idea as to what might be the problem??


The following is a copy of the app.config (copied from a Quickstart)


<?xml version="1.0" encoding="utf-8" ?>



    <section name="modules" type="Microsoft.Practices.Composite.Modularity.ModulesConfigurationSection, Microsoft.Practices.Composite"/>



    <module assemblyFile="Modules/ModuleD.dll" moduleType="ModuleD.ModuleD, ModuleD" moduleName="ModuleD">


        <dependency moduleName="ModuleB"/>



    <module assemblyFile="Modules/ModuleB.dll" moduleType="ModuleB.ModuleB, ModuleB" moduleName="ModuleB"/>

    <module assemblyFile="Modules/ModuleA.dll" moduleType="ModuleA.ModuleA, ModuleA" moduleName="ModuleA">


        <dependency moduleName="ModuleD"/>



    <module assemblyFile="Modules/ModuleC.dll" moduleType="ModuleC.ModuleC, ModuleC" moduleName="ModuleC" startupLoaded="false"/>






Jul 8, 2009 at 5:48 PM

Hi jboggs, 

I tried to reproduce the problem  you mention using the Modularity (Configuration) QuickStart, but could not find the error.
Below you can find some questions that might help us reproduce and solve the problem:

  • Can you list the things you modified from that Quickstart to get the error?
  • Is the within the Shell project?
  • Any additional information that you believe might be relevant

The ConfigurationStore.RetrieveModuleConfigurationSection method uses the ConfigurationManager.GetSection("modules") method to retrieve the ModulesConfigurationSection object from the configuration:

        public ModulesConfigurationSection RetrieveModuleConfigurationSection()
            return ConfigurationManager.GetSection("modules") as ModulesConfigurationSection;

Below are some possible reasons for which the Configuration Manager not finding the section:

  • App.config bad name. The App.config file should be named exactly like that. Any other name will not be recognized by the Configuration Manager.
  • Missplaced App.config. The App.config should be placed in the Shell project (ConfigurationModularity project in the case of the Quickstart) and should be placed in the root project's directory. If the App.config is in any other module it will not be loaded.
  • App.config file Build Action should be configured to None. If it is marked for example as an Embedded Resource it won't be loaded.

Hope it helps!

Matias Bonaventura