【发布时间】:2011-08-07 09:28:46
【问题描述】:
我在我的 PRISM 4.0 应用程序中使用 MEF 来加载模块。 为了确保它们被下载,我让我的 Shell 导入 IPartImportsSatisfiedNotification。然后在 OnImportSatirsfied() 方法中,我可以在调试器中清楚地看到找到了两个模块。 (见下方截图)
但我不断收到此错误消息:
无法找到具有类型的模块 'SalesContactManagement.Modules.NavigationModule.NavigationModule, SalesContactManagement.Modules.NavigationModule,版本=1.0.0.0, Culture=neutral, PublicToken=null' 在导出的模块中。制作 确保模块目录中的模块名称与指定的匹配 模块类型的 ModuleExportAttribute。
知道为什么 MEF 不起作用吗?非常感谢任何帮助。
更新:
有趣的是,当我将 NavigationModule 清空到最低限度时它可以正常工作。
[ModuleExport(typeof(NavigationModule))]
public class NavigationModule : IModule
{
private readonly IRegionManager _regionManager;
private readonly ToolbarViewModel _toolbarViewModel;
public void Initialize()
{
}
//[ImportingConstructor]
//public NavigationModule(RegionManager regionManager)
//{
// //_toolbarViewModel = toolbarViewModel;
// _regionManager = regionManager;
//}
}
但是,一旦我将 ImportingContructor 放在那里,对于已经在 Bootstrapper 中注册的类型,它就会失败。有什么想法吗?
【问题讨论】: