Nancy Bootstrapper for Castle Windsor

by DotNetNerd 18. January 2012 19:37

8e00fa6da668702f8b73ac4caebfbee4On a current project I have decided to use NancyFx for services that expose data to the client via Ajax. The solution already uses Umbraco for CMS capabilities and everything is wired up using Castle Windsor for DI.

From the start I was hoping to just install the nuget packages for hosting in an ASP.NET application and for bootstrapping with Windsor. As it turned out neither worked in my case.
Getting Nancy to run alongside an existing site is pretty well documented, so that went pretty smoothly, once I gave up on the package and just followed the documentation.

The Castle Windsor integration left me with two challenges. The bootstrapper from the package was using a previous version of Castle Windsor, and it creates its own WindsorContainer instance. I was already using the newest version of Castle Windsor and wanted to reuse the WindsorContainer I had already configured for the rest of my application.

So the good news was that the project lives on github, so I took a deeper look at it and made the choice to roll my own - since it is really only two classes. I thought about doing a pull request, to get my changes in, but since I in some ways went another way it probably does not make sense. So instead Ill just share it here in case someone can make use of it... The one thing you will need to do for your self is to create a factory that provides the WindsorContainer – and that way you can share it however you like..

Who am I?

My name is Christian Holm Diget, and I work as an independent consultant, in Denmark, where I write code, give advice on architecture and help with training. On the side I get to do a bit of speaking and help with miscellaneous community events.

Some of my primary focus areas are code quality, programming languages and using new technologies to provide value.

Microsoft Certified Professional Developer

Microsoft Most Valuable Professional

Month List