Module Load fails with mef (CreateModule cannot find ModuleInfo)

Topics: Prism v4 - WPF 4
Jul 6, 2011 at 11:23 PM

Hi All,

I am a newbie to Prism. Using MefBootStrapper I am trying to get my first module to load. In my app.config I have:




   <module assemblyFile="DashBoard.dll" moduleType="DashBoard.DashBoardModule, DashBoard.DashBoardModule, Version=, Culture=neutral, PublicKeyToken=null" moduleName="DashboardModule" />




In my module dll I have:



   [ModuleExport( typeof( DashBoardModule ) )]

   public class DashBoardModule : IModule


       public DashBoardModule()


           Console.WriteLine( "In constructor" )



       public void Initialize()


           Console.WriteLine( "In initialize" )




My application starts and the shell is displayed then the following happens


1)      ModuleManager.Run calls LoadModulesWhenAvailable

2)      Then the first call to ModuleInitializer.CreateModule occurs with my ModuleInfo

3)      In CreateModule the TryGet if is not executed

           if (this.downloadedPartCatalogs.TryGet(moduleInfo, out partCatalog))


but ImportedModueles if is executed which returns IModule for my module


           if (this.ImportedModules != null && this.ImportedModules.Count() != 0)


           Lazy<IModule, IModuleExport> lazyModule = this.ImportedModules.FirstOrDefault(…);

               if (lazyModule != null)


                   return lazyModule.Value;



4)      My module initialize returns successfully which raises LoadModuleCompleted

5)      After that ModuleManager.IModuleTypeLoader_LoadModuleCompleted which calls ModuleInitialer.CreateModule again

6)      In second call to CreateModule neither the TryGet if or ImportedModules if are executed and the exception ModuleInitializeException is thrown


So I think the ModuleManager tries to retrieve the ModuleInfo after the first call to CreateModule but for some reason this fails. I have looked at this thread:

Module Loading Error (

The author adds the following and says it gets around his error:

 Type type = Type.GetType(moduleInfo.ModuleType, false, true);

 but I am not sure if this relates to my error. Also I have studied the quick start ModularityWithMef.Desktop, and used some of its code. If anyone could provide any input why ModuleInfo is not found in CreateModule I would appreciate it.


Jul 6, 2011 at 11:49 PM

I forgot to add the DashBoardModule is in the DashBoard namespace.