Unity & Prism Modularity - Load problems


I need your help again please. I am working on a application with a modular concept.

I want to use Prism and Unity for it. I have looked at the quickstart example from Prism and I also read this <a href="http://msdn.microsoft.com/en-us/library/gg405479%28v=pandp.40%29.aspx" rel="nofollow">article</a> on MSDN.

My actual code looks like:

public class Bootstrapper : UnityBootstrapper { protected override DependencyObject CreateShell() { return this.Container.Resolve<Shell>(); } protected override void InitializeShell() { base.InitializeShell(); var window = this.Shell as Window; if (window != null) { Application.Current.MainWindow = window; } else { throw new ArgumentException("The shell has to be a window."); } } protected override IModuleCatalog CreateModuleCatalog() { return new ConfigurationModuleCatalog(); } }

My config:

<configuration> <configSections> <section name="modules" type="Microsoft.Practices.Prism.Modularity.ModulesConfigurationSection, Microsoft.Practices.Prism"/> </configSections> <modules> <module assemblyFile="Modules/MyApp.Module1.dll" moduleType="MyApp.Module1.Module1Module, MyApp.Module1" moduleName="Module1" /> </modules> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> </configuration>

I have now two problems, the first is that the catalog is not loaded right. For me it seems that the load method is not being called, or something like that.

The second problem is a consequence of the first I think, that the initialize method in my module is not called.

Can anybody help me?


I've taken your code as is in a Desktop Prism project, but it works as expected.

Somewhere in your application, you will need (at minimum):

var bootstrapper = new Bootstrapper(); bootstrapper.Run();

I believe for the config section, the default is for modules to load on startup, so as soon as the Bootstrapper runs, your module should be loaded and initialized. This is exactly what happens for me locally.

This is what my module "initialization" looks like:

using System; using System.Windows; using Microsoft.Practices.Prism.Modularity; namespace MyApp.Module1 { class Module1Module : IModule { public void Initialize() { MessageBox.Show("Hello world!"); } } }

One last thing to check would be to see if it can find the MyApp.Module1.dll in the directory it's looking in, but you would get a ModuleTypeLoadingException after a FileNotFoundException first-chance exception if this wasn't the case.

<strong>Edit:</strong> here is <a href="http://www.subbot.net/personal/external/stackoverflow/PrismSandbox.zip" rel="nofollow">the complete source code</a> for the test solution I made. I cannot think of any differences that make it work for me, but not for you. Check it out.


  • How can I create a Code Module in VBA
  • How can I mimic this behavior in WPF?
  • How to randomize in WPF
  • QT5 and SQLite3 “No query Unable to fetch row”
  • How to have a QTextBrowser to display contents of a QTextEdit?
  • How to fetch the entry text on a different window?
  • QStandardItemModel::removeRows() does not work in my use case
  • change volume of mp3 playing via wmplib in c#
  • Should `System.IO.Path` be concrete?
  • Certificate error when configuring HttpClientFactory
  • Mongolab connection error
  • Adding object to database using table-per-type inheritance in Mvc 4
  • ASP.NET Capture and replace output in Global.asax
  • Mongo server accepts credentials from shell, but not from Java/Scala interface
  • Bash while read LINE extremely slow compared to cat, why?
  • Write a function that calculate the sum of integers in a list in Erlang
  • NLog Configuration API: Using Layouts stored in variables
  • How do I clear the screen in C? [duplicate]
  • Python: Adding to dict of one object in a list changes all dicts of every other object in the list
  • Delete file in internal memory from Android device?
  • Manage different base layouts in Angular2
  • Getting directory of input file (Applescript)
  • Polymer build not to create bundled and unbundled folder
  • How to grep for a specific pattern and print everything above and below that pattern until you reach
  • Convert C# statements including NSubstitute code to VB.net
  • How to debug Shell command after customization
  • Mongodb update() vs. findAndModify() performace
  • Generic classes with Collection getter of other types
  • user data scripts fails without giving reason
  • Ionic storage “get” returns null only on the second call within method
  • multidatatrigger with multibinding in ControlTemplate.Triggers
  • why calling cd shell command through system() or execvp() from a child process won't work?
  • Installing Perl6 and Panda on Ubuntu 15.10. Problems with bootstrap.pl
  • How can I get the full list of running processes on a Mac from a python app
  • Exception creating JSON with LINQ
  • Cloud Code function running twice
  • Thread safety of a fluent like class using clone() and non final fields
  • Converting a WriteableBitmap image ToArray in UWP
  • Switching to Release Build causes runtime error in Web Reference
  • Spark fat jar to run multiple versions on YARN