MapAreaRoute Removed from ASP.NET MVC 2 RC

January 18th, 2010

When I upgraded my CMS to ASP.NET MVC 2, I ran into some problems such as a missing assembly and some routing code changes.

Let's flash back to when I started developing with ASP.NET MVC pre-2.

When I started building my CMS (Content Management System) using ASP.NET MVC 2 Preview 2, Areas were a major factor in my development. I was elated that the ASP.NET MVC Team integrated them into the release, but I ran into a problem...where do I start?

I didn't know how to start building the separate projects to create my modular CMS. After some searching, I found the Walkthrough: Creating an ASP.NET MVC Areas Application using Multiple Projects post. Awesome! This is what I was looking for.

After reading the walkthrough, everything was working fantastic! I'm currently using it today.

Now, flash forward to now. This weekend to be precise.

Over the weekend, I decided to upgrade my version from ASP.NET MVC 2 Preview 2 to ASP.NET MVC 2 RC (Release Candidate).

Since my CMS uses the new feature of areas, I tried to compile my application and ran into the problem of an unknown method called MapAreaRoute. It was there in the Preview 2 release, but now, not in the Release Candidate. In addition to that, I was having a problem "copying" over the areas into my host application. I received an error regarding a missing reference and method called CreateAreaManifest.

Fix the Compile!

First problem was the compiling. I had to get my CMS to compile. After more research, I found a post about Areas in ASP.NET MVC 2. If you have the Google toolbar, just click translate if you really want to read it, but the code should be enough to help you understand what needs to be done.

After changing all of my area "routes.cs" and my global.asax in my main application, everything compiled! Excellent!

Now, the build/copy process

After looking around and doing the research, I was worried that other developers weren't using Areas in ASP.NET MVC either, but I did find this post over at haacked.com (where else?) which explained a couple of things. In ASP.NET MVC 2 RC, they removed an assembly called Microsoft.Web.Mvc.Build.dll.

Ah-HA! I looked for it in futures, but couldn't find it. So I proceeded with the following steps:

  1. Uninstalled ASP.NET MVC 2 RC.
  2. Downloaded and installed ASP.NET MVC 2 Preview 2.
  3. Copied the Microsoft.Web.Mvc.Build.dll to another directory
  4. Uninstalled the ASP.NET MVC 2 Preview 2
  5. Reinstalled the latest version of ASP.NET MVC: ASP.NET MVC 2 RC.

DOH! Moment

I copied the DLL into the C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies directory and recompiled my application.

Still errors!

After a swift open-handed strike to the forehead, I remembered I needed to add the assembly to the GAC by issuing the following command at the command prompt:

gacutil /i Microsoft.Web.Mvc.Build.dll

I started Visual Studio and compiled...and built! Success!

Even though this was a struggle to get everything functioning over the weekend, I'm very impressed with the ASP.NET MVC 2 team for this release and how they made Areas even more modular. The changes made to my code were minimal, so kudos go out to the team!

UPDATE: Problem is not solved. I'm working on a solution, but here is an update as to where I'm currently at.