繁体   English   中英

我该如何处理与MEF相关的ReflectionTypeLoadException异常?

[英]How can I deal with this MEF related ReflectionTypeLoadException exception?

我有三个项目,即Shell.CoreShellServices.Employees ShellServices.Employees导入零件,即后者是外部项目,在任何解决方案项目中均未引用。 Shell ,“ Shell.Core”也是WPF应用程序,而不是类库。 我将其作为DevExpress的项目类型启动,以包含对我所有正确的引用,因为它定义了某些共享的UI组件。

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

例如,当我尝试合成时,出现如下错误:

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

我有什么办法呢? 我是否还应该导入Shell.Core.MappedViewModel ,尽管它已经在引用的项目中? 我是否应该将Core转换为类库,以便它以DLL的形式出现在目录目录中,而MEF会将其作为Services.Employees的依赖项进行加载? 还有其他方法可以解决这个棘手的小问题吗?

看来这件事发生了。 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 both 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 both Core和MEF导入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 both ,所有这些都再次运行良好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM