run all modules

Topics: Prism v1, Prism v2 - WPF 3.5, Prism v2 - WPF 4, Prism v4 - WPF 4
Sep 27, 2010 at 2:54 PM

hello, i'm using the desktop library of prism.

what i want is to get modules in a directory and then, run them.

I do like that:

DirectoryModuleCatalog catalog = new DirectoryModuleCatalog();
catalog.ModulePath = @"C:\Users\Raph\Documents\Visual Studio 2010\Projects\LibraryLoad\LibraryLoad\Modules";

I checked, the modules are loaded in the catalog.
Example of a module:
public class SendEmailClass : IModule
        public void SendEmail()
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress("**", "moi");
            mail.Subject = "Report"; //manage generated subject

            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("");
            smtp.Port = 57;
            smtp.EnableSsl = true; //depending of the smtp server
            NetworkCredential cred = new NetworkCredential("***", "***");
            smtp.Credentials = cred;

        public void Initialize()

But then i want to run them (launch their Initialize()) but i don't find it. I want to run the whole catalog. someone has an idea ? I tried catalog.Initialize(), catalog.Validate() or catalog.Load()

Sep 27, 2010 at 4:05 PM

Do you want to have all the modules initialized during application startup or some later point in time?

If you are trying to do so during application startup, the bootstrapper should handle this for you. Take a look at the Modularity with Unity for WPF Quickstart or the StockTrader RI for examples of how this works.  There are also docs describing how modularity works as well as docs that explain in detail how the quickstarts are put together.

If you are trying to do so later in the process, the ModuleMananger has a LoadModule method that could load the modules individually on demand.  You may also be able to re-run the Run method on the module mananger, but this may have unintended consequences.

Let me know if neither of these approaches help.