[英]Unhandled Error in Silverlight Application Unable to locate the module
My solution contains 4 Silverlight projects - one main, two module projects and last one share project (for common interfaces etc). 我的解决方案包含4个Silverlight项目-一个主项目,两个模块项目和最后一个共享项目(用于通用接口等)。
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): 然后将模块添加到ModuleCatalog中,并将其添加到主项目的派生MefBootstrapper类中(我使用模块的代码注册来代替CreateFromXaml方法):
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: 从上面的代码中可以看到,ModuleCtalog模块名称与ModuleExportAttribute中的模块名称相同,但是在以下情况下出现异常:
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.
未捕获的错误:Silverlight应用程序中的未处理错误无法在导出的模块中找到类型为'SilverlightEnabledService.ModuleDefinitions.ServiceModule,SilverlightEnabledService,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = ca4f032071a86aea'的模块。 Make sure the module name in the module catalog matches that specified on ModuleExportAttribute for the module type.
确保模块目录中的模块名称与在ModuleExportAttribute上为模块类型指定的名称匹配。 в Microsoft.Practices.Prism.Modularity.ModuleInitializer.HandleModuleInitializationError(ModuleInfo moduleInfo, String assemblyName, Exception exception)...
Microsoft.Practices.Prism.Modularity.ModuleInitializer.HandleModuleInitializationError(ModuleInfo moduleInfo,String assemblyName,Exception exception)...
It seems very easy issue but I cannot find solution yet. 似乎很简单的问题,但我找不到解决方案。
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 .
请参阅此博客文章,以概述它们是什么以及如何对其进行调试: 如何调试和诊断MEF故障 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.