Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inheritance security rules violated while overriding member: 'Autofac.Integration.WebApi.AutofacWebApiDependencyResolver.BeginScope()'

I am trying to build an asp.net web api 2.0 application using VS 2012 and asp net web tools for vs 2012 on .Net 4.5.2 framework; when i try to run the application, 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 tried updating all the packages in the solution, adding [assembly: SecurityRules(SecurityRuleSet.Level1)] or [assembly: SecurityRules(SecurityRuleSet.Level2)] but none of them seems to work.

Please help me in resolving this issue I tried all the previous threads but none of them is working.

Thanks in advance.

Edit Below are the list of nugget packages that are referenced in my web api project

  1. Autofac.3.5.2
  2. Autofac.Configuration.3.3.0
  3. Autofac.Extras.DynamicProxy2.3.0.7
  4. Autofac.WebApi.3.1.0
  5. AutoMapper.4.2.1
  6. Castle.Core.3.3.3
  7. Microsoft.AspNet.Mvc.5.2.3
  8. Microsoft.AspNet.Razor.3.2.3
  9. Microsoft.AspNet.Web.Optimization.1.1.3
  10. Microsoft.AspNet.WebApi.5.2.3
  11. Microsoft.AspNet.WebApi.Client.5.2.3
  12. Microsoft.AspNet.WebApi.Core.5.2.3
  13. Microsoft.AspNet.WebApi.WebHost.5.2.3
  14. Microsoft.AspNet.WebPages.3.2.3
  15. Microsoft.Web.Infrastructure.1.0.0.0
  16. Moq.4.5.8
  17. Newtonsoft.Json.8.0.3
  18. WebGrease.1.6.0
like image 357
Amigo Avatar asked May 31 '16 20:05

Amigo


1 Answers

You need to use the Autofac.WebApi2 package with the latest classic Web API as outlined in the docs. The current release version of Autofac.WebApi2 is 3.4.0.

like image 156
Travis Illig Avatar answered Sep 28 '22 11:09

Travis Illig