4

我刚刚开始学习 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.

任何人都可以给出为什么会发生这种情况的一些原因?非常感谢提前和再见...

4

3 回答 3

5

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

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

于 2015-03-10T13:07:07.203 回答
2

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

于 2014-04-10T04:38:57.717 回答
1

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

检查MVC5 - System.TypeAccessException 错误发生在使用来自外部类库的 HtmlHelper 类的扩展方法和 AllowPartiallyTrustedCallers 属性线程以查找可能的解决方案时。

于 2013-10-05T08:56:59.317 回答