![](/img/trans.png)
[英]Attempt by security transparent method to access security critical method failed
[英]Attempt by security transparent method to access security critical type failed
我在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.
我嘗試了以下鏈接中提供的其他解決方案,但它們對我都不起作用。 嘗試通過安全透明方法訪問安全關鍵方法失敗
通過安全透明方法xxx嘗試訪問安全關鍵yy和https://forums.asp.net/t/1939805.aspx
請幫忙
我很確定這是版本問題。 我錯誤地安裝了Autofac.WebApi,Autofac的版本自動為3.xx,然后問題來了。 之后,我意識到必須使用Autofac.WebApi2而不是Autofac.WebApi。 我安裝了Autofac,版本升至4.6.2,然后解決了該問題。
希望能幫助到你
我將Autofac 4.0.0替換為版本Autofac 3.5.0,並將Autofac.Integration.Mvc替換為3.0.0。 這樣就解決了問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.