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?

  • have you tried a search within your project for entire project to FindAll on the following `System.Web.Mvc, Version=3.0.0.0` do you have the expected code in the release folder vs debug folder..? or viceversa – MethodMan Nov 11 '14 at 02:09
  • yes I had done a search all file...didn't find a 3.0.0.0 – ConfusedSleepyDeveloper Nov 11 '14 at 02:15
  • 1
    are you sure you have the correct or updated .dll.. have you tried removing the reference and readding the new one. – MethodMan Nov 11 '14 at 02:18
  • you should check all assemblies deployed like described [here](http://stackoverflow.com/questions/11475112/how-to-find-out-what-assemblies-an-assembly-references) and [here](http://stackoverflow.com/questions/22769806/system-io-fileloadexception-could-not-load-file-or-assembly-log4net) and see which assembly is referencing MVC 3. – BatteryBackupUnit Nov 11 '14 at 06:32
  • 2
    you might also try whether [RefExplorer](http://www.stephan-brenner.com/?page_id=53) helps. – BatteryBackupUnit Nov 11 '14 at 06:35

3 Answers3

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.

sveilleux2
  • 1,442
  • 12
  • 16
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.

Martin Tournoij
  • 26,737
  • 24
  • 105
  • 146
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.

Jason L.
  • 1,125
  • 11
  • 19