简体   繁体   中英

Attempt by security transparent method to access security critical type failed

I am getting below error in MVC4 application

 Attempt by security transparent method  'Autofac.Integration.Mvc.RegistrationExtensions.RegisterControllers(Autofac.Cont    ainerBuilder, System.Reflection.Assembly[])' to access security critical type 'Autofac.Builder.IRegistrationBuilder`3<System.Object,Autofac.Features.Scanning.ScanningActivatorData,Autofac.Builder.DynamicRegistrationStyle>' failed.

 Assembly 'Autofac.Integration.Mvc, Version=3.0.0.0, Culture=neutral,  
 PublicKeyToken=17863af14b0044da' is marked with the  
 AllowPartiallyTrustedCallersAttribute, and uses the level 2 security 
 transparency model.  Level 2 transparency causes all methods in 
 AllowPartiallyTrustedCallers assemblies to become security transparent by 
 default, which may be the cause of this exception.

I tried different solutions given in below links but none of them work for me Attempt by security transparent method to access security critical method failed

Attempt by security transparent method xxx to access security critical yy and https://forums.asp.net/t/1939805.aspx

Please help

I am pretty sure this is the version issue. I installed Autofac.WebApi by mistake, the version of Autofac was automatically 3.xx Then the issue came. After that I realized I had to use Autofac.WebApi2 instead of Autofac.WebApi. I installed, Autofac version went up to 4.6.2, then booom the issue was solved.

Hope it helps

I replaced Autofac 4.0.0 with version Autofac 3.5.0 and Autofac.Integration.Mvc to 3.0.0. This resolved the problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM