【问题标题】:Attempt by security transparent method to access security critical type failed尝试通过安全透明方法访问安全关键类型失败
【发布时间】:2017-03-15 15:13:51
【问题描述】:

我在 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

请帮忙

【问题讨论】:

  • 你有机会看看这个吗?github.com/autofac/Autofac/issues/459
  • 您需要在此处添加更多内容,例如您的 NuGet packages.config,以便我们看到您引用的内容。

标签: c# asp.net-mvc asp.net-mvc-4 autofac


【解决方案1】:

我很确定这是版本问题。我错误地安装了Autofac.WebApi,Autofac的版本自动为3.x.x。然后问题来了。之后我意识到我必须使用 Autofac.WebApi2 而不是 Autofac.WebApi。我安装了,Autofac版本升到4.6.2,然后booom问题就解决了。

希望对你有帮助

【讨论】:

  • 这是解决问题的正确方法。我还使用了 WebApi 而不是 WebApi2
【解决方案2】:

我将 Autofac 4.0.0 替换为 Autofac 3.5.0 版本并将 Autofac.Integration.Mvc 替换为 3.0.0。这解决了问题

【讨论】:

    猜你喜欢
    • 2013-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-06
    • 2014-06-09
    • 1970-01-01
    • 2013-10-04
    • 2015-06-20
    相关资源
    最近更新 更多