How can I insert an object into the WCF implementation of IErrorHandler using Castle Windsor?

I am developing a set of services using WCF. The app injects dependencies with Castle Windsor. I added an IErrorHandler implementation added to services through an attribute. Everything is still working. IErrorHandler object (of a class named FaultHandler is applied correctly and called.

Now I am adding a magazine. Castle Windsor is configured to enter a registration object (instance of IOurLogger ). It works. But when I try to add it to FaultHandler , my logger is null.

The FaultHandler code looks something like this:

 class FaultHandler : IErrorHandler { public IOurLogger logger { get; set; } public bool HandleError(Exception error) { logger.Write("Exception type {0}. Message: {1}", error.GetType(), error.Message); // Let WCF handle things its way. We only want to log. return false; } public void ProvideFault(Exception error, MessageVersion version, Message fault) { } } 

This throws its own exception, since logger is null when HandleError() called.

The registrar is successfully entered into the service itself and can be used there, but for some reason I cannot use it in FaultHandler .

Refresh . Here is the relevant part of the Windsor configuration file (edited to protect the innocent):

 <configuration> <components> <component id="Logger" service="Our.Namespace.IOurLogger, Our.Namespace" type="Our.Namespace.OurLogger, Our.Namespace" /> </components> </configuration> 
+4
source share
1 answer

The logger is never set for this class, so you get a null ref error. Can you share your configuration file where you install the dependencies?

0
source

All Articles