views:

376

answers:

2

I'm new to Castle Windsor and am confused about the order in the config file. This is taken from the GettingStarted1 sample. The HttpServiceWatcher class takes an IFailureNotifier implementor in it's constructor. However, no matter how I order the two components that implement this interface -- AlarmFailureNotifier and EmailFailureNotifier -- I always get EmailFailureNotifier. I know you can override which is chosen using parameters and a "service lookup" reference, but I thought that the order of declaration is used when other mechanisms are not.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="castle"
             type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,Castle.Windsor" />
  </configSections>

  <castle>
    <components>

      <component
        id="httpservicewatcher"
        type="GettingStartedPart1.HttpServiceWatcher, GettingStartedPart1">
      </component>

      <component
        id="alarm.notifier"
        service="GettingStartedPart1.IFailureNotifier, GettingStartedPart1"
        type="GettingStartedPart1.AlarmFailureNotifier, GettingStartedPart1" />

      <component
        id="email.notifier"
        service="GettingStartedPart1.IFailureNotifier, GettingStartedPart1"
        type="GettingStartedPart1.EmailFailureNotifier, GettingStartedPart1" />

      <component
        id="form.component"
        type="GettingStartedPart1.Form1,GettingStartedPart1" />

    </components>

  </castle>
</configuration>
A: 

I don't know which version you're using, but I believe this was a bug some time ago and it has been corrected in the build server version. Try that one and see what happens.

Also, you could use default components like this: Castle Windsor and default components

gcores
I downloaded CastleProject-1.0-RC3.msi. Is this the latest version?
Decker
That's not the latest version, you'll want to download the trunk from source control (if you want to skip having to build it yourself, just download the last succesfull build from the builder server here: http://builds.castleproject.org/cruise/index.castle)
Bittercoder
+1  A: 

This was resolved with Castle 2.0 (that went RTM early last year).

The latest version of Castle is 2.1.1:

http://sourceforge.net/projects/castleproject/files/InversionOfControl/2.1/Castle-Windsor-2.1.1.zip/download

Castle's releases are always a bit tricky to find (they need to update their site). I always refer to the Project list:

http://www.castleproject.org/castle/projects.html

You want: MicroKernal/Windsor

eduncan911
Hi Eric, how could we improve the download process? Why do you find it tricky?
Mauricio Scheffer
Hello Mauricio!!! I think what confuse most people I talk to is this page: http://www.castleproject.org/castle/download.html Many end up downloading the RC3 as it seems the only "complete" package. Perhaps inserting comments under each title: Windsor 2.1 - The Castle MicroKernel is an inversion of control container that was designed towards extensibility (in normal font, under the big bold header). Just a suggestion! Keep up the great work!
eduncan911

related questions