title: InvalidCastException is thrown after installing ASP.NET MVC 4 Beta
body: <p>I get the following exception after installing ASP.NET MVC 4 Beta on a machine with ASP.NET MVC 3.</p>
  
  <blockquote>
    <p>System.InvalidCastException was unhandled by user code
          Message=[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast 
            to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates 
            from 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, 
            PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 
            'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. 
            Type B originates from 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 
            in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'.
          Source=System.Web.WebPages.Razor</p>
    
    <p>StackTrace:</p>
    
    <p>at System.Web.WebPages.Razor.WebRazorHostFactory.GetRazorSection(String virtualPath)
           at System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfig(String virtualPath, String physicalPath)
           at System.Web.WebPages.Razor.RazorBuildProvider.GetHostFromConfig()
           at System.Web.WebPages.Razor.RazorBuildProvider.CreateHost()
           at System.Web.WebPages.Razor.RazorBuildProvider.EnsureGeneratedCode()
           at System.Web.WebPages.Razor.RazorBuildProvider.get_CodeCompilerType()
           at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
           at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
           at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
           at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
           at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
           at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
           at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
           at System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath)
           at System.Web.Mvc.BuildManagerViewEngine.FileExists(ControllerContext controllerContext, String virtualPath)
           at System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List`1 locations, String name, String controllerName, String areaName, String cacheKey, String[]&amp; searchedLocations)
           at System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]&amp; searchedLocations)
           at System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache)
           at System.Web.Mvc.ViewEngineCollection.&lt;>c__DisplayClassc.b__b(IViewEngine e)
           at System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths)
           at System.Web.Mvc.ViewEngineCollection.FindView(ControllerContext controllerContext, String viewName, String masterName)
           at System.Web.Mvc.ViewResult.FindView(ControllerContext context)
           at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
           at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
           at System.Web.Mvc.ControllerActionInvoker.&lt;>c__DisplayClass1c.b__19()
           at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
           at System.Web.Mvc.ControllerActionInvoker.&lt;>c__DisplayClass1c.&lt;>c__DisplayClass1e.b__1b()
           at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
           at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
           at System.Web.Mvc.Controller.ExecuteCore()
           at [project_namespace].Controllers.GlobalizationController.ExecuteCore() in [file_path]
           at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
           at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
           at System.Web.Mvc.MvcHandler.&lt;>c__DisplayClass6.&lt;>c__DisplayClassb.b__5()
           at System.Web.Mvc.Async.AsyncResultWrapper.&lt;>c__DisplayClass1.b__0()
           at System.Web.Mvc.Async.AsyncResultWrapper.&lt;>c__DisplayClass8`1.b__7(IAsyncResult _)
           at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
           at System.Web.Mvc.MvcHandler.&lt;>c__DisplayClasse.b__d()
           at System.Web.Mvc.SecurityUtil.b__0(Action f)
           at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
           at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
           at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
           at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
           at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)</p>
  </blockquote>
  
  <p>This blocks me completely and while I would like to keep the beta, I might need to remove it completely in order to get rid of the exception.</p>