[英]Attempt by security transparent method to access security critical type failed
I am getting below error in MVC4 application 我在MVC4应用程序中遇到以下错误
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 通过安全透明方法xxx尝试访问安全关键yy和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. 我错误地安装了Autofac.WebApi,Autofac的版本自动为3.xx,然后问题来了。 After that I realized I had to use Autofac.WebApi2 instead of Autofac.WebApi. 之后,我意识到必须使用Autofac.WebApi2而不是Autofac.WebApi。 I installed, Autofac version went up to 4.6.2, then booom the issue was solved. 我安装了Autofac,版本升至4.6.2,然后解决了该问题。
Hope it helps 希望能帮助到你
I replaced Autofac 4.0.0 with version Autofac 3.5.0 and Autofac.Integration.Mvc to 3.0.0. 我将Autofac 4.0.0替换为版本Autofac 3.5.0,并将Autofac.Integration.Mvc替换为3.0.0。 This resolved the problem 这样就解决了问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.