1

我有三个项目,即Shell.CoreShellServices.EmployeesShell从 导入部件Services.Employees,即后一个项目是外部的,在任何解决方案项目中都没有引用。除了Shell`Shell.Core' 也是一个 WPF 应用程序,而不是一个类库。我将它作为 DevExpress 的项目类型开始,为我包含所有正确的引用,因为它定义了某些共享的 UI 组件。

Services.Employees确实 reference Core,它定义了它使用的某些基类。现在,当启动应用程序时Shell,它应该加载Core,然后它执行 MEF 组合,Services.Employees从 DirectoryCatalog 加载部分,但 MEF 看到依赖项Core并希望从该目录加载它们,尽管主机应用程序已经引用了这些Core依赖项。

例如,当我尝试组合时,我收到如下错误:

异常:“TypeLoadException”:无法从程序集“XTime900.Shell.Core,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”加载类型“Shell.Core.MappedViewModel`1”。

我有什么办法摆脱这种情况?我是否也应该 import Shell.Core.MappedViewModel,尽管它已经在引用的项目中?我是否应该转换Core为类库,以便它将作为 DLL 出现在目录目录中,而 MEF 会将其作为 ? 的依赖项加载Services.Employees?有没有其他方法可以解决这个棘手的小问题?

4

1 回答 1

0

看起来这件事发生了。Shell.Core.MappedViewModel1, referenced by the plugins, loaded the ViewModel types. Then, the MEF plugins referenced this project, and during composition, couldn't find the right objects. When I factored View Models out into a separate project, referenced by bothCore` 和 MEF 导入,都再次运行良好。

于 2013-11-16T04:15:00.667 回答