【问题标题】:Attempt by security transparent method xxx to access security critical yy尝试通过安全透明方法 xxx 访问安全关键 yy
【发布时间】:2013-10-04 09:04:06
【问题描述】:

我刚刚开始学习 ASP.NET MVC 并遵循 ASP.NET MVC 教程。

我正在使用 Visual Studio Express 2013 RC for Web 并认为这可能是我的问题的原因,因为分页教程是使用 VS2012 编写的。

一切正常;但是当我将分页添加到其中一个页面时,使用教程中的所有说明添加 PagedList.mvc,一切都编译得很好;当我到达特定页面时,我收到以下错误消息:

Attempt by security transparent method'PagedList.Mvc.HtmlHelper.PagedListPager(System.Web.Mvc.HtmlHelper, PagedList.IPagedList, System.Func2) 访问安全关键类型'System.Web.Mvc.MvcHtmlString' failed.

Assembly 'PagedList.Mvc, Version=4.3.0.0, Culture=neutral, enter code here PublicKeyToken=abbb863e9397c5e1' 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.

任何人都可以说明为什么会发生这种情况?非常感谢提前和再见......

【问题讨论】:

  • 这与 PagedList.Mvc 使用 System.Web.Mvc 版本 4 引用 .NET 4.0 或 2.0 编译有关。您是否有 PagedList.Mvc 的源代码,以便您可以使用版本 5 重新编译它?

标签: asp.net-mvc pagedlist


【解决方案1】:

【讨论】:

    【解决方案2】:

    我有同样的问题,然后我更新到 PagedList.Mvc.4.5.0.0 并且它工作了

    【讨论】:

      【解决方案3】:

      对我来说,页面在Html.ActionLink helpers 上以同样的方式消失:

      尝试通过安全透明的方法 'Microsoft.Web.Mvc.LinkExtensions.ActionLink(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression1<System.Action1>, System.String, System.Object)' 访问安全关键类型 'System.Web.Mvc.MvcHtmlString' 失败。

      解决方案是执行以下操作:

      Uninstall-Package Mvc4Futures
      

      然后:

      Install-Package Microsoft.AspNet.Mvc.Futures -Version 5.0.0
      

      https://www.nuget.org/packages/Microsoft.AspNet.Mvc.Futures/5.0.0

      【讨论】:

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