castle-windsor

How can I inject an object into an WCF IErrorHandler implementation with Castle Windsor?

I'm developing a set of services using WCF. The application is doing dependency injection with Castle Windsor. I've added an IErrorHandler implementation that is added to services via an attribute. Everything is working thus far. The IErrorHandler object (of a class called FaultHandler is being applied properly and invoked. Now I'm addi...

Castle IoC - ISubDependencyResolver that supports Release(...)?

Is it possible to build something that works like an ISubDependencyResolver but also supports Release(...)? I have a situation where I want to be able to resolve a derived class of Fruit in the constructor of a Blender: abstract class Fruit { } class AppleBlender { AppleBlender(Apple a) { } } Apple is unfortunately in a ...

How can I use Windsor to inject a dependency into an ASP.NET MVC model?

I have a a model class that needs access to my repository class (used for DB access). I have created an interface for my repository and have successfully configured Castle Windsor to inject my the appropriate IRepository-based class into my controllers via a custom ControllerFactory. I'm having a little more trouble figuring out how to...

Use Enum as Parameter in Windsor Configuration File

Hi guys, how would I preset a Windsor configuration file parameter with an Enum specified entry such as "EntryType" below? I currently have this: <component id="test.service" service=".." type=".." lifestyle="transient"> <parameters> <entryType>EntryType.Test</entryType> </parameters> </component> Where ...

Container Resolve based on criteria

I'm trying to implement the Strategy pattern while using Windsor container. Here is what I have: public class OrderProcessor { ... public OrderProcessor(ITaxStrategy strategy) {} public void Process(Order order) { order.Tax = strategy.CalcTax(order); } } The problem is, how do I configure my container (other c...

Constructor on type: "Namespace.type" not found.

Hello, I am using Castle.Windsor as an IOC. So I am trying to resolve a service type in the constructor of an HTTPHandler. I keep receiving this error, "Constructor on type: "Namespace.type" not found." My configuration has the following entries for service type: IDocumentDirectory <component id="restricted.content.directory" service=...

Castle Windsor Interceptor for private/protected method

Hi all, Is it true that in order for castle windsor's interceptor to intercept a method, that method needs to be declare public? ...

Resolving a Generic with a Generic parameter in Castle Windsor

I am trying to register a type like IRequestHandler1[GenericTestRequest1[T]] which will be implemented by GenericTestRequestHandler`1[T] but I am currently getting an error from Windsor "Castle.MicroKernel.ComponentNotFoundException : No component for supporting the service " Is this type of operation supported? Or is it to far removed ...

logging in log4net to different appenders based on circumstances

Hi there, I am using log4net and in one class require logging to a RollingFile appender, but then in another class, I wish to log to the event log + rolling file + console appender. What is the best practice? and could I see some sample code? By the way to make things more difficult, I am using Castle Windsor Logging Facility with Log...

How to create multiple components of a service with c'tor dependencies

I'd like to create several similar services which can be destinguished and accessed by their names (=keys). For the service implementation I want to use classes with c'tor dependencies like this: public interface IXYService { string Tag { get; set; } } public class _1stXYService : IXYService { public _1stXYService(string Tag) { ...

Castle Windsor: auto-register types that have dependency in constructor

Most of the examples I see for Castle Windsor auto-register type that derive from some IFoo. However, I often have simple components (services) that just required IFoo in the constructor: public class Service { public Service(Service2 service, IFoo foo) {} } public class Service2 { public Service2(IFoo foo) {} } How do I make Wind...

How can I override a component registered in Castle Windsor?

I'm just starting with Windsor, so please be gentle :) I have a scenario where I want to be able to override/replace components placed inside a windsor container. Read on ... In my prod code, I want to be able to register a component which implements a base class, and use a container to resolve the implementer. So far, using container...

Authorization and Windsor

I'm trying to implement my custom authorize attribute like: public class MyCustomAuth : AuthorizeAttribute { private readonly IUserService _userService; public MyCustomAuth(IUserService userService) { _userService= userService; } ... continued } I am using Castle Windsor for automatically resolve the depende...

How to get instance of service in Windsor Castle

Hi everybody! In a multilayer application (ASP MVC: UI project, DAL project) i registered in web.config the components. Now i have this problem: Unit of Work pattern has do be implemented and i need to get the current instance of a particular service. The registration of the services happened in the UI project, but i need to get the c...

Project Windsor - Repository Extending DataContext

Before I begin I will say this: I have to extend DataContext in my repository because I'm calling stored procedures and ExecuteMethodCall is only available internally. Many people don't seem to know this, so please don't say "just don't extend DataContext". I've just started using Windsor as my IoC container. My controller happily doe...

Linq to SQL DataContext Windsor IoC memory leak problem

I have an ASP.NET MVC app that creates a Linq2SQL datacontext on a per-web-request basis using Castler Windsor IoC. For some reason that I do not fully understand, every time a new datacontext is created (on every web request) about 8k of memory is taken up and not released - which inevitably causes an OutOfMemory exception. If I forc...

Inject AutoMapper

I have been working on injecting AutoMapper into controllers. I like the implementation of Code Camp Server. It creates a wrapper around AutoMapper's IMappingEngine. The dependency injection is done using StructureMap. But I need to use Castle Windsor for my project. So, how do we implement the following dependency injection and set-up u...

Could not find schema information for the element 'castle'.

Hello! I'm creating a Custom tag in my web.config. I first wrote the following entry under the configSections section. <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" /> But, when I try to create a castle node inside the configuration node as below <castl...

The element 'configuration' in namespace 'MyWindsorSchema' has invalid child element 'configSections' in namespace 'MyWindsorSchema'

Hello, In order to create the following section, <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" /> I downloaded and put the "CastelWindsorSchema" in my C drive (as it was suggested by the read-me file). I referenced it this way in the Web.Config: (I kept e...

Castle Windsor ResolveAll that throws when any of registered services cannot be resolved

It seems that current behaviour of Castle Windsor (2.0) method container.ResolveAll(Type type) is to ignore all services that cannot be resolved due to missing dependencies. What is recommened way to resolve all services + throwing exception when any of services cannot be resolved? ...