Ninject程序集与引用的程序集不匹配 [英] Ninject assembly does not match referenced assembly

查看:82
本文介绍了Ninject程序集与引用的程序集不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置:

  • ASP.NET MVC3
  • Ninject v2.2.1.4
  • Ninject v3.0.0.15
  • Ninject.MVC3 v3.0.0.6
  • Ninject.Web.Common v3.0.0.7

使用NuGet,我的UnitTest项目引用了Ninject v2.2.1.4

Using NuGet, my UnitTest project references Ninject v2.2.1.4

我的Web项目引用了Ninject v3.0.0.15,Ninject.MVC3和Ninject.Web.Common

My Web Project references Ninject v3.0.0.15, Ninject.MVC3 and Ninject.Web.Common

问题:

在我的Web项目的bin文件夹中打开win资源管理器时,我构建了解决方案,并且可以看到Ninject v2.2.1.4复制到了我的Web项目的bin目录中.然后被Ninject v3.0.0.15取代.

With win explorer open at the bin folder of my web project, I build my solution and I can see Ninject v2.2.1.4 copied into the bin directory of my web project. And then being replaced by Ninject v3.0.0.15.

当我按F5进行调试时,Ninject.dll v3.0.0.15被Ninject v2.2.1.4替换,从而导致以下错误:

When i hit F5 to debug, Ninject.dll v3.0.0.15 gets replaced with Ninject v2.2.1.4 causing the following error :

无法加载文件或程序集"Ninject,版本= 3.0.0.0,区域性=中性,PublicKeyToken = c7192dc5380945e7"或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配. (来自HRESULT的异常:0x80131040)

有什么作用?

推荐答案

一些想法:

  1. 仅在调试版本中,您才间接引用了 v2 Ninject版本.举例来说,我猜你是什么时候做的 您的调试版本,而发布版本则构建您的Test项目 不会建立您的测试项目.
  2. 在构建时,您是否偶然发现将v2 DLL放入垃圾箱时正在构建哪个项目?那你就会 能够找出哪个项目引用了v2版本并 能够缩小搜索范围(即,如果不是 Test项目,答案将变得更加明显).
  3. 在不同项目中引用多个版本绝不是一个好主意.
  4. 您是否检查了Web.config和App.config引用指向的内容?
  1. Only in your debug build did you have an indirect reference to the v2 Ninject version. Case in point, I'm guessing when you are doing your debug build you build your Test project while a release build does not build your Test project.
  2. When you were building, did you happen to notice what project was being built when the v2 DLL was placed in the bin? Then you'll be able to figure out what project is referencing the v2 build and be able to narrow down your search (i.e. the answer would become quite a bit more obvious if it wasn't the Test project).
  3. Never a good idea to reference multiple versions in different projects.
  4. Did you check out what your Web.config and App.config references were pointing to?

这篇关于Ninject程序集与引用的程序集不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆