繁体   English   中英

尝试使用安全透明方法xxx来访问安全性关键yy

[英]Attempt by security transparent method xxx to access security critical yy

我刚刚开始学习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.Func 2)来访问安全关键类型'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.

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

对我来说,页面在Html.ActionLink助手上以同样的方式死亡:

尝试通过安全透明方法'Microsoft.Web.Mvc.LinkExtensions.ActionLink(System.Web.Mvc.HtmlHelper,System.Linq.Expressions.Expression 1<System.Action 1>,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

看起来这个问题是由MVC 5的细节引起的。

检查MVC5 - 当使用带有AllowPartiallyTrustedCallers属性线程的外部类库的HtmlHelper类的扩展方法来查找可能的解决方案时,会发生System.TypeAccessException错误

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM