title: Level 2 transparency causes all methods in AllowPartiallyTrustedCallers
body: <p>i am using PagedList Nuget package in my asp.net mvc 5 application.
  below is my source which i am trying to:</p>
  
  <pre><code>@Html.PagedListPager(Model, page =&gt; Url.Action("StudentList",
  new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))
  </code></pre>
  
  <p>when i am using it on my view, it is throwing an exception:</p>
  
  <pre><code>System.TypeAccessException was unhandled by user code
    HResult=-2146233021
    Message=Attempt by security transparent method 'PagedList.Mvc.HtmlHelper.PagedListPager(System.Web.Mvc.HtmlHelper, PagedList.IPagedList, System.Func`2&lt;Int32,System.String&gt;)' to access security critical type 'System.Web.Mvc.MvcHtmlString' failed.
  
  Assembly 'PagedList.Mvc, Version=4.0.0.0, Culture=neutral, 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.
    Source=PagedList.Mvc
    TypeName=""
    StackTrace:
         at PagedList.Mvc.HtmlHelper.PagedListPager(HtmlHelper html, IPagedList list, Func`2 generatePageUrl)
         at ASP._Page_Views_Registration_StudentList_cshtml.Execute() in c:\Users\maifs\SkyDrive\SchoolManagementSystem\SMSApp\Views\Registration\StudentList.cshtml:line 57
         at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
         at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
         at System.Web.WebPages.StartPage.RunPage()
         at System.Web.WebPages.StartPage.ExecutePageHierarchy()
         at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
         at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
         at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
         at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
         at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
         at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
         at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
    InnerException: 
  </code></pre>
  
  <p>i tried to use these attributes in assemblyinfo.cs</p>
  
  <pre><code>[assembly: SecurityRules(SecurityRuleSet.Level2)]
  </code></pre>
  
  <p>and </p>
  
  <p><code>[assembly: AllowPartiallyTrustedCallersAttribute]</code> but it didn't work. Kindly guide me . thanks</p>