"Could not load file or assembly 'Ninject.Web.Common'" error on "new StandardKernal()"

1

I have a web API asp.net project (.net framework 4.6.1). I imported the Ninject.Web.WebApi.WebHost nuget package, which created a Ninject.Web.Common.cs file in my App_Start folder.

When I try running my web app, I get this error:

System.IO.FileLoadException: 'Could not load file or assembly 'Ninject.Web.Common, 
Version=3.3.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)'

This happens on this line in the Ninject.Web.Common file:

    private static IKernel CreateKernel()
    {
        var kernel = new StandardKernel(); // happens here
        try
        {
            kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
            kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
            RegisterServices(kernel);
            return kernel;
        }
        catch
        {
            kernel.Dispose();
            throw;
        }
    }

I have these Ninject packages installed. All their dependencies seem to be fine:

  • Ninject v3.3.4
  • Ninject.Web.Common v3.3.1
  • Ninject.Web.Common.WebHost v3.3.1

What am I doing wrong?

c#
asp.net
ninject
ninject.web.mvc
asked on Stack Overflow Jan 12, 2019 by Andrio

1 Answer

1

Seems like I fixed the problem. What I did was:

  1. I uninstalled those three dependencies
  2. Reinstalled them (same versions)
  3. Also installed Ninject.Web.WebApi
answered on Stack Overflow Jan 12, 2019 by Andrio

User contributions licensed under CC BY-SA 3.0