Daniel Hoelbling talks about programming
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:
The list of assemblies to register is pretty outdated, I failed because I didn’t reference the DictionaryAdapter.
Instead you need to reference:
Register the HttpModule is no longer needed. If you try to add
<httpModules> <add name="monorail" type="Castle.MonoRail.Framework.EngineContextModule, Castle.MonoRail.Framework" /> </httpModules>
to your config things will break. The EngineContextModule has disappeared from the source and is no longer needed.
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"> <config> <add key="connection.driver_class" value="NHibernate.Driver.SQLite20Driver" /> <add key="dialect" value="NHibernate.Dialect.SQLiteDialect" /> <add key="connection.provider" value="NHibernate.Connection.DriverConnectionProvider" /> <add key="connection.connection_string" value="Data Source=nhibernate.db3;Version=3" /> </config> </activerecord>
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.