1
votes

My solution contains 4 Silverlight projects - one main, two module projects and last one share project (for common interfaces etc).

Main and module projects don't have references to each other (just to share project).

You can find definitions of my modules below:

[ModuleExport("ServiceModule", typeof(ServiceModule), InitializationMode = InitializationMode.WhenAvailable)]
public class ServiceModule : IModule

[ModuleExport("ViewModule",
    typeof(ViewModule),
    DependsOnModuleNames = new string[] { "ServiceModule" },
    InitializationMode = InitializationMode.WhenAvailable)]
public class ViewModule : IModule

And I added modules to ModuleCatalog into derived MefBootstrapper class of main project (I used code registration of modules instead of CreateFromXaml method):

protected override void ConfigureModuleCatalog()
{
    ModuleCatalog.AddModule(
      new ModuleInfo()
      {
          ModuleName = "ServiceModule",
          ModuleType = "SilverlightEnabledService.ModuleDefinitions.ServiceModule, SilverlightEnabledService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ca4f032071a86aea",
          Ref = "SilverlightEnabledService.xap",
          InitializationMode = InitializationMode.WhenAvailable
      }
    );

    ModuleCatalog.AddModule(
      new ModuleInfo()
      {
          ModuleName = "ViewModule",
          ModuleType = "RedOrBlackModule.ModuleDefinitions.ViewModule, RedOrBlackModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ca4f032071a86aea",
          Ref = "RedOrBlackModule.xap",
          InitializationMode = InitializationMode.WhenAvailable,
          DependsOn = (new Collection<string>(new string[] { "ServiceModule" }))
      }
    );
}

As see from code above, ModuleCtalog module name is the same as module name in ModuleExportAttribute, but I get exception below:

Uncaught Error: Unhandled Error in Silverlight Application Unable to locate the module with type 'SilverlightEnabledService.ModuleDefinitions.ServiceModule, SilverlightEnabledService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ca4f032071a86aea' among the exported modules. Make sure the module name in the module catalog matches that specified on ModuleExportAttribute for the module type. в Microsoft.Practices.Prism.Modularity.ModuleInitializer.HandleModuleInitializationError(ModuleInfo moduleInfo, String assemblyName, Exception exception)...

It seems very easy issue but I cannot find solution yet.

1

1 Answers

0
votes

There are several reasons why the module might not be found. See this blog post for an overview of what they are and how to debug them: How to Debug and Diagnose MEF Failures.