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=3.5.0.0, 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.
Mixed Messages
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?).
The Fix
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:
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
The above should fix your troubles.
thanx man. had the same problem
ReplyDeleteLifesaver, thank you :)
ReplyDeleteThanks for the post, it was exactly what the doctor ordered :)
ReplyDeleteThanks. This problem occurs on a fresh install of windows 7 and vs2010, so nothing to do with previous installs.
ReplyDeleteNo worries, folks.
ReplyDelete@Gavin...you are right. I've confirmed with Scott Guthrie and Eilon Lipton (from the Asp.Net team) that this is indeed a templating problem and has nothing to do with previous builds or past MVC releases.
The template has been fixed for the release version of VS2010.
Cheers,
-jc
Thanks. This helped me out as well.
ReplyDeleteThanks. Turns an frustating evening into a happy ending
ReplyDeleteThanks!!!
ReplyDeleteThanks a lot
ReplyDelete