title: Error: Inheritance security rules violated by type: 'System.Web.WebPages.Razor.WebPageRazorHost'
body: <p>Out of nowhere my ASP.NET MVC 4 solution gives me this error:</p>
  
  <blockquote>
    <p>Inheritance security rules violated by type: 'System.Web.WebPages.Razor.WebPageRazorHost'. Derived types must either match the security accessibility of the base type or be less accessible.</p>
  </blockquote>
  
  <p>I Googled the problem and everybody says it has happened when anyone updates the solution from one version to another. But I didn't update my solution, just change the IDE from VS12 to VS13. Is this what creates the problem?</p>
  
  <p>The full stack trace is as follows:</p>
  
  <blockquote>
    <p>[TypeLoadException: Inheritance security rules violated by type: System.Web.WebPages.Razor.WebPageRazorHost'. Derived types must either match the security accessibility of the base type or be less accessible.]
       System.Web.WebPages.Razor.RazorBuildProvider.get_CodeCompilerType() +0
       System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) +59
       System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() +209
       System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +30
       System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +9971917
       System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +299
       System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +103
       System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +165
       System.Web.Compilation.BuildManager.GetObjectFactory(String virtualPath, Boolean throwIfNotFound) +33
       System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath) +40
       System.Web.Mvc.BuildManagerViewEngine.FileExists(ControllerContext controllerContext, String virtualPath) +54
       Microsoft.Web.Mvc.FixedRazorViewEngine.Microsoft.Web.Mvc.IViewEngineProxy.FileExists(ControllerContext controllerContext, String virtualPath) +42
       Microsoft.Web.Mvc.ViewEngineFixWorker<code>1.FileExists(ControllerContext controllerContext, String virtualPath) +57
       Microsoft.Web.Mvc.&lt;&gt;c__DisplayClass4.&lt;GetPathFromGeneralName&gt;b__0(String path) +66
       System.Web.WebPages.DefaultDisplayMode.GetDisplayInfo(HttpContextBase httpContext, String virtualPath, Func</code>2 virtualPathExists) +90
       System.Web.WebPages.&lt;>c__DisplayClassb.b__8(IDisplayMode mode) +66
       System.Linq.WhereSelectListIterator<code>2.MoveNext() +103
       System.Linq.Enumerable.FirstOrDefault(IEnumerable</code>1 source, Func<code>2 predicate) +94
       System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func</code>2 virtualPathExists, IDisplayMode currentDisplayMode, Boolean requireConsistentDisplayMode) +297
       System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func<code>2 virtualPathExists, IDisplayMode currentDisplayMode) +108
       Microsoft.Web.Mvc.ViewEngineFixWorker</code>1.GetPathFromGeneralName(ControllerContext controllerContext, List<code>1 locations, String name, String controllerName, String areaName, String cacheKey, String[]&amp; searchedLocations) +653
       Microsoft.Web.Mvc.ViewEngineFixWorker</code>1.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]&amp; searchedLocations) +1508
       Microsoft.Web.Mvc.ViewEngineFixWorker<code>1.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache) +329
       Microsoft.Web.Mvc.FixedRazorViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache) +66
       System.Web.Mvc.&lt;&gt;c__DisplayClassc.&lt;FindView&gt;b__b(IViewEngine e) +68
       System.Web.Mvc.ViewEngineCollection.Find(Func</code>2 lookup, Boolean trackSearchedPaths) +182
       System.Web.Mvc.ViewEngineCollection.Find(Func<code>2 cacheLocator, Func</code>2 locator) +110
       System.Web.Mvc.ViewEngineCollection.FindView(ControllerContext controllerContext, String viewName, String masterName) +329
       System.Web.Mvc.ViewResult.FindView(ControllerContext context) +135
       System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +230
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39
       System.Web.Mvc.&lt;>c__DisplayClass1a.b__17() +74
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func<code>1 continuation) +388
       System.Web.Mvc.&lt;&gt;c__DisplayClass1c.&lt;InvokeActionResultWithFilters&gt;b__19() +72
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList</code>1 filters, ActionResult actionResult) +303
       System.Web.Mvc.Async.&lt;>c__DisplayClass2a.b__20() +155
       System.Web.Mvc.Async.&lt;>c__DisplayClass25.b__22(IAsyncResult asyncResult) +184
       System.Web.Mvc.Async.WrappedAsyncResult<code>1.End() +136
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
       System.Web.Mvc.&lt;&gt;c__DisplayClass1d.&lt;BeginExecuteCore&gt;b__18(IAsyncResult asyncResult) +40
       System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +47
       System.Web.Mvc.Async.WrappedAsyncResult</code>1.End() +151
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
       System.Web.Mvc.Async.&lt;>c__DisplayClass4.b__3(IAsyncResult ar) +47
       System.Web.Mvc.Async.WrappedAsyncResult<code>1.End() +151
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
       System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
       System.Web.Mvc.&lt;&gt;c__DisplayClass8.&lt;BeginProcessRequest&gt;b__3(IAsyncResult asyncResult) +45
       System.Web.Mvc.Async.&lt;&gt;c__DisplayClass4.&lt;MakeVoidDelegate&gt;b__3(IAsyncResult ar) +47
       System.Web.Mvc.Async.WrappedAsyncResult</code>1.End() +151
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
       System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9651116
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155</p>
  </blockquote>