Posts tagged nhibernate
Switching development to mono
Apr 17th
Last week I started writing a new application using FluentNHibernate and ASP.NET MVC. Initially I was working on it in my windows vm as I was having trouble getting the latest version of MonoDevelop to work. That is all fixed now so I decided it was time to checkout the code and see if it worked.
So first thing does it compile. Yes!
Next I tried to run my tests. Nup didn’t work. I get the following exception “System.TypeInitializationException: An exception was thrown by the type initializer for NHibernate.Cfg.Environment”.
I spent forever digging around to find out why. Another lib I am using is MvcContrib and I am using the TestControllerBuilder class. It turns out that if you create an instance of this class BEFORE configuring NHibernate then you get the exception, create it afterwards and it works fine. Argghh. Frustrating. I took a look at the TestControllerBuilder class and I can’t see what it is doing to cause that.
The next problem was that SQLite doesn’t work so well on Mono and you need to use Mono.Data.SQLite instead. This required writing a custom Driver for NHibernate which is no big deal – but another step nonetheless. I have submitted a patch to the NHibernate team here and the FluentNHibernate team here
Ok so run the tests again and everything is working now.
Yay, it is kind of exciting to get this working. I am going to try and do all my development on linux now.. MonoDevelop is not as nice as VisualStudio + ReSharper though so I am not sure if this will last!
