Why is my project still looking for Inject version 3.0.0.0

1

In the NinjectWebCommon.cs I have this:

private static IKernel CreateKernel()
{
    var kernel = new StandardKernel();
    try
    {
        kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
        kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

        RegisterServices(kernel);
        return kernel;
    }
    catch
    {
        kernel.Dispose();
        throw;
    }
}

When I run my ASP.NET MVC app it crashes on that method saying:

An exception of type 'System.IO.FileLoadException' occurred in Ninject.dll but was not handled in user code

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

I have deleted my Ninject DLLs from the References and added them again from the NuGet manager and now my packages file looks like this, but still getting that error:

  <package id="Ninject" version="3.2.2.0" targetFramework="net451" />
  <package id="Ninject.MVC3" version="3.2.1.0" targetFramework="net451" />
  <package id="Ninject.Web.Common" version="3.2.3.0" targetFramework="net451" />
  <package id="Ninject.Web.Common.WebHost" version="3.2.3.0" targetFramework="net451" />

What else should I do?

c#
ninject

3 Answers

0

If you want to easily figure out what project use what version, a solution is to go to the packages directory and look for the Ninject-[version] directory and delete, rename it or move it elsewhere. When you return to visual studio you should see what project is now complaining about not having it.

answered on Stack Overflow Dec 19, 2015 by sveilleux2
0

Update your asp.net MVC assemblies from the manage NuGet packages for solution in the library package manager.

I just had this same issue and this solved it. It's probably because of a conflict between the MVC version and Ninject assemblies version.

answered on Stack Overflow Oct 6, 2016 by ali shalash • edited Oct 6, 2016 by Martin Tournoij
0

I also had this issue and it turned out to be that when I was doing a Clean or Rebuild in Visual Studio, it was not actually clearing out the entire contents of the bin directory, leaving behind some assemblies. Since the build was not replacing these old assemblies, it then threw mismatched-version errors at runtime. The solution for me was to navigated to that folder and manually purge all of the files in the bin folder. After manually deleting and rebuilding the solution, my runtime errors disappeared.

answered on Stack Overflow May 3, 2019 by Jason L.

User contributions licensed under CC BY-SA 3.0