Friday, 29 March 2013

Razor and Mono on Ubuntu

I just thought I'd write a little about the process of getting Xizi's new Razor-based template system working under Mono on Ubuntu.

I followed the guide at http://www.integratedwebsystems.com/2011/06/get-mvc3-razor-running-on-mono/#more-1156 by Nathan Bridgewater. This is immensely useful with lots of no-nonsense information on the process.

However, I did encounter a problem with how I'd set up my project in Visual Studio 2010. I had used the "Add Deployable Dependencies" feature which created a folder containing the various System and Microsoft namespace DLLs that would be required for the deployment. This configuration does NOT work under Mono, and rather frustratingly I wasted a good couple of hours trying to fix the problem rather than taking a step back and re-reading the instructions in Nathan's article.

The error that is produced complains about the version of DotNetOpenAuth that is linked to by the Microsoft.Web.WebPages.OAuth.dll file included in the dependencies. I tried following the thread of fixing this by trying to source a copy of DotNetOpenAuth, including the project it is from, of finding the right version for Mono and this version of .Net and the further I got then the more it unraveled.

In the end, I stopped, removed all that I had done and went back to the original deployment set up. After removing the Microsoft.Web.WebPages.OAuth.dll file and then receiving the error "System.Security.SecurityException: No access to the given key" I read about the same message in Nathan's article which gave a very basic instruction - "Delete Microsoft.Web.Infrastructure.dll from you bin directory" [sic]. The simple act of removing the Microsoft namespace DLLs from the included dependencies worked perfectly.

So, thanks to Nathan Bridgewater for compiling such a good guide; I'll try to read it more thoroughly next time :)