Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Register module from "Executable" instead of Library

$
0
0
Hello,

I have a project with 2 module libraries ModuleALibrary and ModuleBLibrary using a IUnityContainer to register types.

My Main project uses a Bootstrapper to initialize my UnityContainer.
namespace MainProject
{
 public class MyBootstrapper : UnityBootstrapper
 {
        protected override IModuleCatalog CreateModuleCatalog()
        {
            ModuleCatalog catalog = new ConfigurationModuleCatalog();
            catalog.AddModule(typeof (MainModule), InitializationMode.WhenAvailable,
                              "ModuleB");
            return catalog;
    }
}
}
As you can see my Main project contains a class/module (MainModule) that I need my container to reference. MainModule is dependent upon ModuleB.

As my Main project generates a .exe and not a .dll how can I add my MainModule class to my configuration file and remove the coding line catalog.AddModule().

I know that a Module should not be in a .exe project but I have this requirement for my specific case.

Below my configuration file where I need to add a <module> with an "exe" assemblyFile (yes this sound strange ;):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="modules" type="Microsoft.Practices.Prism.Modularity.ModulesConfigurationSection, Microsoft.Practices.Prism"/>
  </configSections>

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

    <!-- Main module depends upon the modules above -->
    <module assemblyFile="ModuleBLibrary.dll" 
            moduleType="ModuleBLibrary.ModuleB, ModuleBLibrary" 
            moduleName="ModuleB">
      <dependencies>
        <dependency moduleName="ModuleA"/>
      </dependencies>
    </module>
   
  </modules>
</configuration>
I know that this is possible in Silverlight as we can add a XAP file but how can we do with a WPF application?

Thank you for your help.

Sincerely,
Linvi

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>