Developing with ASP.Net MVC Preview 2 and MVC RTM, side by side.
Retaggr is built on ASP.Net MVC Preview 2. We've been delighted with how well it's stood up, being an effectively alpha technology. Actually this is not that surprising - the MS MVC implementation is really just a few thin layers on top of regular ASP.Net. Those layers are awesome though, and Phil Haack and co. deserve heaps of praise.
So we've had no real problems, the only issue is upgrading alpha tech as they become beta, and ultimately, the final product. Retaggr got stuck on Preview 2, the rest of the world is now on RTM. There's a not insignificant jump from Preview 2 to 3 that a simple search and replace won't solve, so it's put off until a rainy day. I do however now need to do development on the same machine, using MVC RTM.
If you're in the same situation, these steps may help you.
You may want to create a restore point, and backup of your registry at each step, just in case something goes catastrophically wrong. The usual works on my machine disclaimer applies, and the machine in question is Vista.

- Step 0: Copy the Preview 2 dlls (System.Web.MVC, System.Web.Abstractions, System.Web.Routing) to a known location - you'll reference them later.
- Step 1: Uninstall MVC Preview 2 from Programs/Features.
- Step 2: Install .Net 3.5 Sp1. Reboot.
- Step 3 : Install MVC RTM. You now have a MVC RTM machine, but no Preview 2 support.
- Step 4 : Open regedit to
hkey_classes_root\installer\assemblies\global, and delete the references to System.Web.MVC, System.Web.Abstractions and System.Web.Routing. The MVC RTM installer creates a dependency on these items which we have to manually remove, otherwise the next step would fail. - Step 5 : Using gacutil (or windows explorer to c:\windows\assemblies), uninstall the 3.5 versions of System.Web.MVC, System.Web.Abstractions, System.Web.Routing. (In explorer, you can just hit delete).
The key issue we just got around was that the runtime looks to the GAC first to resolve the mvc dlls. With them removed, we can now bin deploy which ever MVC version we need.
Open up your preview 2 project, and remove the references to the 3 dlls mentioned before. Replace them with references to the dlls you copied in the first step. Your project should now compile fine, and you can xcopy deploy.
To test RTM is working correctly, create a new ASP.Net MVC Web Application in Visual Studio. If you look at the references for the 3 key dlls, they're to c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\, which suits us just fine. Because they're gone from the GAC, set those 3 "Copy Local" to true, so they'll come along for the ride when you build and deploy.
You should now be able to enjoy the new goodies in RTM, while supporting your Preview 2 apps.
Note that the Visual Studio new item templates (for creating controllers, views, and such) will not compile on preview 2, but are trivial to implement yourself (replacing "ActionResult" for "void", and similar). You can actually modify these templates (they're built using t4) and create your own preview 2 versions - find theme in C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC\CodeTemplates
Notes
- If your Visual Studio now crashes when opening a view, it's not related to what we've done here. See this blog post for the resolution - just need to install a patch.
- If you're used to specifying the View's model in the codebehind as a strongly typed class, you may be wondering what to do with RTM's new view template, which does not give you a code-behind. (I presume this change is to further "encourage" us to stick to the model-view-controller seperation of concerns paradigm).
Option 1 : Create a codebehind .cs class manually, specify it in your aspx (
CodeBehind="MyView.aspx.cs"), and then just include it in your project.Option 2: You may be tempted to try this in the .aspx :
System.Web.Mvc.ViewPage<Models.MyModel>It won't work for Preview 2 projects (it does in RTM). This post gives a workaround which you may find useful, just make sure the rest of your team understand the somewhat cryptic CLR syntax!
This entry was posted on Monday, March 30th, 2009 at 11:24 am and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.