14

I'm developing a web api as part of a MVC/API ASP.NET on VS 2013, MVC 5, API 2, but my AutofacWebApiDependencyResolver throws an exception every time I try to register it:

Additional information: Inheritance security rules violated while overriding member: 'Autofac.Integration.WebApi.AutofacWebApiDependencyResolver.BeginScope()'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.

I've tried a lot of things unsuccessfully. Keep in mind I have the latest autofac.webapi.nupkg but it still not working.

e-sushi
  • 13,786
  • 10
  • 38
  • 57
abarreiro
  • 233
  • 3
  • 8

2 Answers2

18

You need to install a NuGet package called Autofac ASP.NET MVC5 Integration as well as Autofac ASP.NET Web API 2 Integration and of course the latest version of Autofac which currently is 3.2.0.

For some reason these packages are not first in the results but rather page 2, which is kind of a bummer.

Dimitar Dimitrov
  • 14,868
  • 8
  • 51
  • 79
9

When you look for the nuget package, search for "autofac webapi 2". Do not use the package "Autofac.Webapi", use "Autofac.WebApi2". This fixed the problem for me.

Michael
  • 386
  • 2
  • 9