You’ll run into this quickly if you try to do something similar to the following:
<%= Html.ActionLink("About", "About") %>
You’ll get an error message as such:
The type 'System.Web.Routing.RouteValueDictionary' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Routing, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I am running Visual Studio 2010 and have created a new, empty ASP.NET MVC project. Using the standard template (with some basic controllers and view in place), this problem is not present.
I have had previous installs of MVC through the betas and the LCTP in VS2010, so this error might be presenting itself because of that. It says it’s looking for a version 3.5 when I’m working in 4.0, so there is a versioning thing going on here.
Still, the compiler in the IDE has no problem spitting out the code and launching the development web server; it’s at only at execution time…erm…compilation time on the server? when the mis-match is detected (expecting something different to be pulled from GAC, perhaps?).
Thankfully, it’s easy to resolve. Just tell the compiler what you really, really want.
Great, now I have Posh Spice stuck in my head…
The project template that generates the web.config file in the root of the project is missing two assemblies in the compilation configuration section.
Update your assemblies section as follows:
<add assembly="System.Web.Abstractions, Version=18.104.22.168, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
The above should fix your troubles.