Ninject assembly does not match referenced assembly

6k views Asked by At

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

There are 1 answers

0
Ted On

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?