views:

744

answers:

2

I'm currently reading Pro ASP.NET MVC Framework by Sanderson. In the book he recommends setting up IoC using Castle Windsor, and he points out that the download automatically installs it and registers the Castle DLLs in the GAC. Well, at this point in time (5/4/2010), the Castle Project no longer has a downloadable installer that sets this up. Its all broken out into their individual subprojects with the raw files contained in zipped folders. Sadly there's no installation documentation that I can find about how to set it up. Being the noob that I am, I'm stuck and now forced to ask #1 where should castle windsor live on my hard drive? #2 how do I manually register the dlls properly? And, #3 should I be angry at the project maintainers for their oversight?

Here's the link: http://www.castleproject.org/castle/download.html

+1  A: 

You are looking for the Castle MicroKernel/Windsor project: http://www.castleproject.org/container/index.html

Here is a link to the "Getting Started" page: http://www.castleproject.org/container/gettingstarted/part1/index.html

Once you have downloaded the ZIP file, extract it to a known location on your hardrive (inside the Visual Studio solution directory is normal).

Follow the "Getting Started" guide, it steps you through which DLL's to reference in your project, and how to use it

Good luck!

Alastair Pitts
+6  A: 

Sanderson's book is already somewhat outdated about the Castle - ASP.NET MVC integration.

There is no oversight here really, the Castle developers team decided that the project was getting too big to be efficiently managed, so they split it. So now each of these new projects ships as a separate bundle, which includes the necessary DLLs.

There is no installer because it's really not necessary. As with most open source .Net libraries (like NHibernate, log4net, Rhino.Mocks, Moq, and lots others) you get the DLL, put it in some directory in your project (most people call it lib or Dependencies), then from your project you add a reference to the DLLs in this directory. No need to mess with the GAC at all.

You also need to get MvcContrib (the one that says MVCContrib.Extras.release.zip), which implements the Windsor - ASP.NET MVC integration (controller factory and extensions to register controllers, among other things). In fact, MvcContrib already includes Windsor so that's all you really need.

Mauricio Scheffer
I, too, implemented based on Sanderson's book. I just got the Castle dll files and put them in a local directory of my project and then set a reference to them. The files I have are: Castle.Core.dll, Castle.DynamicProxy.dll, Castle.MicroKernel.dll, Castle.Windsor.dll. I'm not sure if I need all of them, but I have them if I do.
Scott
@Scott: just get MvcContrib, it's all there.
Mauricio Scheffer
So, from the sound of things the MvcContrib will do the same IoC as CastleWindsor for handling separation of concerns. Is that correct? Would I be better off abandoning the Sanderson book and going to another source? If so, what book or website do you recommend for learning MVC?
@user300266: no, MvcContrib is just the *glue*. The actual IoC container is Windsor. I don't have Sanderson's book but my guess is that only this one bit is outdated. For example, I think there's a `WindsorControllerFactory` implementation in the book. It's ok to know how it works, but the actual bits are already in MvcContrib, so you don't need to type the code yourself.
Mauricio Scheffer