Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does autofac supports the new Web Api 2

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.

like image 556
abarreiro Avatar asked Dec 26 '13 20:12

abarreiro


Video Answer


1 Answers

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.

like image 159
Dimitar Dimitrov Avatar answered Sep 21 '22 02:09

Dimitar Dimitrov