[Fix] - Attempt by security transparent method WebMatrix WebData PreApplicationStartCode Start

Wikitechy | 13524 Views | asp.net | 07 Jun 2016


Scenario :

Migrating a project created with MVC current version to the next version. The migrated project throws error at runtime.

Error :

Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)' failed

Fix : 

  • The solution is to install Nuget Package Microsoft.AspNet.WebHelpers as follows:
                             Install-Package -Id  Microsoft.AspNet.WebHelpers
  • Upon installing Microsoft.AspNet.WebHelpers via NuGet the next error that follows is 
  • "Could not load file or assembly 'WebMatrix.Data, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)."
  • To fix the above error, install the below Nuget Package:
                            Install-Package Microsoft.AspNet.WebPages.Data.

  • Now close and reopen the upgraded MVC projects to execute without errors.

Fixes are applicable to the following versions of Visual Studio:

  • Visual Studio 2010
  • Visual Studio 2012
  • Visual Studio 2013
  • Visual Studio 2015

Related Error Tags :

  • c# - Is ASP.NET MVC 5 incompatible with the WebMatrix
  • How to fix System.MethodAccessException in ASP.NET MVC
  • Upgrading from MVC 4 to MVC 5
  • MVC4 project
  • Upgrading a Web Application Using SimpleMembership to ASP.NET
  • Attempt by security transparent method 'WebMatrix.WebData preapplicationstartcod
  • How to Fix SimpleSecurity Error when Upgrading from in C#
  • attempt by security transparent method 'WebMatrix.WebData
  • attempt by security transparent method 'system.web.mvc.preapplicationstartcode.start()' to access


Bug Bounty

Join our Community