Loading two modules from the same assembly using the app.config

Topics: Prism v4 - WPF 4
May 19, 2011 at 5:10 PM

Hi there,


I have two modules in the same assembly and I tried to add this in the app.config,

 <module
      assemblyFile="PartsFinder.Chimera.Modules.VendorManagement.dll"
      moduleType="PartsFinder.Chimera.Modules.VendorMapping.VendorMappingModule, PartsFinder.Chimera.Modules.VendorManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
      moduleName="VendorMappingModule"
      startupLoaded="true">
      <dependencies>
        <dependency moduleName="PartsFinderModule"/>
      </dependencies>
    </module>
    <module
     assemblyFile="PartsFinder.Chimera.Modules.VendorManagement.dll"
     moduleType="PartsFinder.Chimera.Modules.VendorManagement.VendorReturnPolicyManagementModule, PartsFinder.Chimera.Modules.VendorManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
     moduleName="VendorMappingModule"
     startupLoaded="true">
      <dependencies>
        <dependency moduleName="PartsFinderModule"/>
      </dependencies>
    </module>

Except I get the following error. "The entry 'VendorMappingModule' has already been added. (C:\\Projects\\branches..." I have been looking through the docs, I see that if I was using a ModuleCatalog.xaml file I could use "Modularity:ModuleInfoGroup" but just putting it in the app.config I don't have that option, or at least don't see how it would be done. Can someone point me in the right direction please?

Thanks!

May 19, 2011 at 5:46 PM

Which IoC are you using Unity or MEF?

May 19, 2011 at 6:30 PM

Unity... Sorry about that.

May 19, 2011 at 6:51 PM

you only have to include the assembly once eveything from there is automagically accessible from within the container.

So you just need get an instance of your VendorReturnPolicyManagementModule.  It's kind of the point of the container.

May 19, 2011 at 7:17 PM

The what is the point ofmoduleType and moduleName? Speaking of that - I see an error, I have the moduleName listed twice... I wonder what fixing that will do?

May 19, 2011 at 7:22 PM

Ah - There, fixing the configuration file so that the moduleName=VendorMappingModule wasn't listed twice solve the problem. For the sake of clarity here is the entire file listing again - notice in the VendorManagement section the module name is different.

<module
      assemblyFile="PartsFinder.Chimera.Modules.VendorManagement.dll"
      moduleType="PartsFinder.Chimera.Modules.VendorMapping.VendorMappingModule, PartsFinder.Chimera.Modules.VendorManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
      moduleName="VendorMappingModule"
      startupLoaded="true">
      <dependencies>
        <dependency moduleName="PartsFinderModule"/>
      </dependencies>
    </module>
    <module
     assemblyFile="PartsFinder.Chimera.Modules.VendorManagement.dll"
     moduleType="PartsFinder.Chimera.Modules.VendorManagement.VendorReturnPolicyManagementModule, PartsFinder.Chimera.Modules.VendorManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
     moduleName="VendorReturnPolicyManagementModule"
     startupLoaded="true">
      <dependencies>
        <dependency moduleName="PartsFinderModule"/>
      </dependencies>
    </module>

Thanks for the prompt responses! (even if it was my own dumb error)

May 19, 2011 at 8:16 PM
Edited May 19, 2011 at 8:17 PM

never used the config file for that, I always just set it up so that all module are in "Modules" and the Prism boot loader knows about it.  Then all modules compile and xcopy to that folder.  At least that is how I do it with MEF as the IoC