I am trying to use Autofac.WebApi with an ASP.NET MVC4 WebApi project. I installed the latest Autofac and Autofac.WebApi using Nuget, but at runtime on application start when trying to register the GlobalConfiguration DependencyResolver, I get this exception thrown:
Could not load file or assembly ‘Autofac, Version=2.6.2.859,
Culture=neutral, PublicKeyToken=17863af14b0044da’ or one of its
dependencies. The located assembly’s manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
The latest version of Autofac is 2.6.3 while Autofac.WebApi is on 2.6.2. It seems that Autofac.WebApi tries to call the specific version 2.6.2 but can’t find it. I had bindingRedirect in my web.config from any version to 2.6.3 but the problem was still happening.
To solve the issue, I uninstalled both packages then installed Autofac specifying version 2.6.2 and Autofac.WebApi ignoring dependencies (otherwise it will uninstall old autofac and install 2.6.3).