Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading an ASP.NET MVC 3 Project to ASP.NET MVC 4

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'.

like image 584
Omar AMEZOUG Avatar asked Oct 07 '22 07:10

Omar AMEZOUG


1 Answers

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" />
like image 119
Dave Hogan Avatar answered Oct 10 '22 08:10

Dave Hogan