Ninject assembly does not match referenced assembly

拥有回忆 提交于 2020-01-03 07:52:20

问题


Setup:

  • 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

Using NuGet, my UnitTest project references Ninject v2.2.1.4

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

Problem:

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.

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

Could not load file or assembly 'Ninject, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

What gives?


回答1:


Some thoughts:

  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?


来源:https://stackoverflow.com/questions/10637799/ninject-assembly-does-not-match-referenced-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!