I have an asp.net MVC3 project I made an upgrade to asp.net mvc4 following this tutorial: http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806
I get the following error when I execute the project
[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'.
Step by step instructions can be found here: http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806
Specifically you're interested in binding redirects in your web.config.
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" 
         publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
  </dependentAssembly>
and don't forget to add the following to your <appSettings>
  <add key="webpages:Version" value="2.0.0.0" />
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With