Daniel Hoelbling-Inzko talks about programming

Rails with obstacles

Posted by Daniel Hölbling on May 26, 2009

Important: Most of the information in this post about outdated MonoRail docs is now also outdated since I submitted a patch to the castle documentation project to fix the issues raised in this post.

Yesterday I decided to build a website with Castle.Monorail to learn another take on the MVC (besides the Microsoft one). Since the last official release of Monorail is quite outdated I just compiled the trunk version to start from the current release.

Doing so is very simple, just do a:

svn checkout http://svn.castleproject.org:8080/svn/castle/trunk

Some time ago Roelof Blom made an effort to make the build more user-friendly, so you don’t need any tools installed besides .NET to compile all castle assemblies. Just run ClickToBuild.cmd and it will invoke nant (also in SVN) etc, run a complete compile of all projects and place the output in


(Did I mention this is awesome? Building the trunk before was a nightmare!)

I then followed the Monorail getting-started samples from the website and was quite frustrated with how outdated that documentation really is.

Please read through the original documentation as it usually still applies, I’ll just list the things that I had to adapt for the trunk version to work:

Creating the Project Sceleton:

Registering Assemblies:

The list of assemblies to register is pretty outdated, I failed because I didn’t reference the DictionaryAdapter.
Instead you need to reference:

  1. Castle.Components.Binder.dll
  2. Castle.Components.Common.EmailSender.dll
  3. Castle.Components.DictionaryAdapter.dll
  4. Castle.Components.Validator.dll
  5. Castle.Core.dll
  6. Castle.MonoRail.Framework.dll
  7. Castle.MonoRail.Framework.Views.NVelocity.dll
  8. NVelocity.dll

HttpModule registration

Register the HttpModule is no longer needed. If you try to add

      type="Castle.MonoRail.Framework.EngineContextModule, Castle.MonoRail.Framework" />

to your config things will break. The EngineContextModule has disappeared from the source and is no longer needed.

Bringing ActiveRecord to the party

The configuration has changed since RC3 and you no longer need to prefix all keys with a hibernate. Things will break if you do. You’ll get a exception stating:

Could not find the dialect in the configuration

Kind of an misleading exception, once you remove the leading nhibernate. from your config values you’ll be set.

That’s all as for now, I decided to not go with a “real” database like MsSql during development but to go against a SqlLite database. To do so I changed the AR configuration to this:

<activerecord isWeb="true">
        value="NHibernate.Driver.SQLite20Driver" />
        value="NHibernate.Dialect.SQLiteDialect" />
        value="NHibernate.Connection.DriverConnectionProvider" />
        value="Data Source=nhibernate.db3;Version=3" />

You then need to reference the System.Data.SQLite.dll and you’re set (grab the release from SourceForge).

Update: In case you try the SqlLite database I found SqlLite Administrator very useful for looking at the database.

Filed under net, castle, programmierung
comments powered by Disqus

My Photography business


dynamic css for .NET