Aug 312012

A few days ago I installed VS 2012, and everything seemed fine. But today I went to work on an existing MVC 3 app, and I couldn’t get it to work. It turns out there are some fairly simple changes that you need to make in the csproj and web.config files for your MVC 3 project in order to get it to work again after installing VS 2012. Hopefully this post will save someone else the same headache that I went through.

After installing VS2012, When I tried to run the MVC 3 application, I got the following yellow screen of death upon startup:

Server Error in ‘/My.Mvc.App’ Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1705: Assembly ‘My.Mvc.App, Version=, Culture=neutral, PublicKeyToken=null’ uses ‘System.Web.WebPages, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35′ which has a higher version than referenced assembly ‘System.Web.WebPages, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35′

So, I looked in my web config, and saw this:

<add assembly="System.Web.WebPages, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

It seemed logical to me to take that and simply make it Problem solved? NO! Don’t do this! For reasons unclear to me, this causes an AccessViolationException to get thrown from somewhere within the Razor view engine (which is what System.Web.WebPages is).

After going down many rabbit holes, it turned out that this was a documented breaking change in the MVC 4 release notes. In order to fix the issue, you have to specify the version of System.Web.WebPages and System.Web.Helpers in your project references. In addition, you have to add a magic appSettings key to your web.config:

<add key="webpages:Version" value=""/>

Once you do that, everything works fine, and you can start “roundtripping” your MVC 3 project between VS 2010 and VS 2012 as promised.

Read the release notes linked above for more details. Hope it helps.

 Posted by at 3:25 PM

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>