Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempt by security transparent method xxx to access security critical yy

I'm just starting to learn ASP.NET MVC and following an ASP.NET MVC tutorials.

I'm using Visual Studio Express 2013 RC for Web and think that could be the reason for my problem, because the tutorial for paging is written using VS2012.

Everything is works fine; but when I add paging to one of the pages, using all the instructions in the tutorial for adding PagedList.mvc, everything compiles fine; when I get to the specific page, I receive this error message:

Attempt by security transparent method 'PagedList.Mvc.HtmlHelper.PagedListPager(System.Web.Mvc.HtmlHelper, PagedList.IPagedList, System.Func2) to access security critical type '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.

Anybody can give some reason why this situation is happening? Many thanks in advance and bye ...

like image 406
Manuel Rivera Avatar asked Feb 15 '23 03:02

Manuel Rivera


1 Answers

For me, the page was dying in the same way on Html.ActionLink helpers:

Attempt by security transparent method 'Microsoft.Web.Mvc.LinkExtensions.ActionLink(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression1<System.Action1>, System.String, System.Object)' to access security critical type 'System.Web.Mvc.MvcHtmlString' failed.

The solution was to do the following:

Uninstall-Package Mvc4Futures

Then:

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

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

like image 171
shanabus Avatar answered Apr 08 '23 11:04

shanabus