You've to load/register your modules. You can do this in many ways.
Register/Load in Code
In the bootstrapper.cs
:
protected override void ConfigureModuleCatalog()
{
Type ModuleAType = typeof(ModuleAModule);
ModuleCatalog.AddModule(new ModuleInfo()
{
ModuleName = moduleAType.Name,
ModuleType = moduleAType.AssemblyQualifiedName,
InitializationMode = InitializationMode.WhenAvailable
});
}
Register/Load from Directory
In the bootstrapper.cs
:
protected override IModuleCatalog CreateModuleCatalog()
{
return new DirectoryModuleCatalog() { ModulePath = @".\Modules" };
}
Create the Modules
directory in the bin\Debug directory and copy/paste the ModuleA.dll
file to this directory.
In the ModuleAModulle.cs
you can define the module name and initialization method:
[Module(ModuleName="ModuleA", OnDemand=true)]
public class ModuleAModule : IModule
{
public void Initialize()
{
throw new NotImplementedException();
}
}
Register/Load from XAML File
Add a new Resource Dictionary to your shell project and set the build action to Resource. (In this example it's called XamlCatalog.xaml
)
<Modularity:ModuleCatalog
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Modularity="clr-namespace:Microsoft.Practices.Prism.Modularity;assembly=Microsoft.Practices.Prism">
<Modularity:ModuleInfo Ref="file://ModuleA.dll" ModuleName="ModuleA" ModuleType="ModuleA.ModuleAModule, ModuleA, Version=1.0.0.0" InitializationMode="WhenAvailable" />
</Modularity:ModuleCatalog>
In the bootstrapper.cs
:
protected override IModuleCatalog CreateModuleCatalog()
{
return Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml(
new Uri("/ProjectNameHere;component/XamlCatalog.xaml", UriKind.Relative));
}
Don't forget to copy/paste the ModuleA.dll
file to the root of the project, because you're referencing to it in the XamlCatalog.xaml
file.
Register/Load from App.config File
In the bootstrapper.cs
:
protected override IModuleCatalog CreateModuleCatalog()
{
return new ConfigurationModuleCatalog();
}
In the 'App.config':
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="modules" type="Prism.Modularity.ModulesConfigurationSection, Prism.Wpf"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<modules>
<module assemblyFile="Modules/ProjectNameHere.ModuleA.dll" moduleType="ProjectNameHere.ModuleA.ModuleAModule, ProjectNameHere.ModuleA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="ModuleA" startupLoaded="true" />
<module assemblyFile="Modules/ProjectNameHere.ModuleB.dll" moduleType="ProjectNameHere.ModuleB.ModuleBModule, ProjectNameHere.ModuleB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="ModuleB" startupLoaded="true" />
<module assemblyFile="Modules/ProjectNameHere.ModuleC.dll" moduleType="ProjectNameHere.ModuleC.ModuleCModule, ProjectNameHere.ModuleC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="ModuleC" startupLoaded="true" />
</modules>
</configuration>
I've got this information from the Prims Introduction course on Pluralsight.