2016-11-02 41 views
1

我收到以下錯誤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. 

我試着在下面的鏈接,給出不同的解決方案,但沒有人對我 Attempt by security transparent method to access security critical method failed

工作Attempt by security transparent method xxx to access security critical yyhttps://forums.asp.net/t/1939805.aspx

請幫

+0

難道u得到一個機會,看看這個.https://github.com/autofac/Autofac/issues/459 – FakeisMe

+0

你需要把更多的在這裏,像你的NuGet packages.config所以我們可以看到你在參考什麼。 –

回答

2

我用版本Autofac 3.5.0和Autofac.Integration.Mvc替換Autofac 4.0.0至3.0.0。這解決了問題

2

我很確定這是版本問題。我錯誤地安裝了Autofac.WebApi,Autofac的版本自動爲3.x.x.然後問題出現了。之後,我意識到我必須使用Autofac.WebApi2而不是Autofac.WebApi。我安裝了,Autofac版本升到了4.6.2,然後解決了問題。

希望它可以幫助

相關問題