Ninject assembly does not match referenced assembly
Asked Answered
D

1

9

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?

Decembrist answered 17/5, 2012 at 14:35 Comment(1)
So I simply deleted Ninject v2.2.1.4 from my list of packages. When running/debugging the solution v3.0.0.15 remains. My problem is solved but I wish I understood or knew why it was being overwritten in the first place. I carefully reviewed all references and v2.2.1.4 was not being referenced anywhere. I even manually referenced the v3 dll but to no avail, v2 was always being copied ovwer when debugging. If I did a build v3 would be copied... apologies if this doesn't help anyone else but if someone knows the answer i would love to know. TIA...Decembrist
G
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?
Gamogenesis answered 20/8, 2013 at 5:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.