castle-windsor

How To Get Automatic Registration With Castle Windsor

I recently read Ayende's blog post on automatic registration working with XML Configuration. I would like to do exactly what he does, but his code snippet doesn't work for me. The Register method doesn't exist on my container object. Here's his code: var container = new WindsorContainer(new XmlInterpreter()); container.Register( Al...

Castle Windsor - Nested runtime dependencies

I am using Castle Windosr container. I want to be able to specify some constructor dependencies at runtime which you can obviously do by using a Resolve overload that takes a dictionary, all good and fine. However if I want to specify runtime dependency for a dependency of the root then I'm lost, at the moment I've worked around by expli...

How do I tell Windsor to add an Interceptor to all components registered that implement IMustBeIntercepted

If I registered several components with Windsor. IAnimal provides BigAnimal IPerson provides SmellyPerson IWhale provides BlueWhale etc.. pretty standard component registeration all the above types implement IMustBeIntercepted, how do I tell the container add an interceptor to all types that implement IMustBeImplemented so that when R...

Castle Windsor - One class implementing multiple interfaces

I register my two interfaces on application start as so:- container.Register(Component.For(typeof(IEntityIndexController)).ImplementedBy(typeof(SnippetController)).LifeStyle.Transient); container.Register(Component.For(typeof(ISnippetController)).ImplementedBy(typeof(SnippetController)).LifeStyle.Transient); Then when I try to run an ...

Resolving classes without registering them using Castle Windsor

Take the following useless program: class Program { static void Main(string[] args) { IUnityContainer unityContainer = new UnityContainer(); IWindsorContainer windsorContainer = new WindsorContainer(); Program unityProgram = unityContainer.Resolve<Program>(); Program castleProgram = windsorContai...

Castle-Windsor Fluent Interface: How to register all implementations of all interfaces?

I have two assemblies EDC2.DAL and EDC2 where EDC2.DaoInterfaces defines a bunch of interfaces for data access objects to objects in the EDC2.Domain namespace. These are all implemented by classes in EDC2.DAL. So to give an example: Assembly EDC2 Namespace EDC2.DaoInterfaces ICustomerDao IProductDao Assembly EDC2.DAL Name...

who calls the constructor witth parameter (Castle.Windsor)

I am learning castle.windsor following the tutorial online. this is the simple sample code: public class Form1 { private readonly HttpServiceWatcher serviceWatcher; private System.ComponentModel.Container components = null; public Form1() { InitializeComponent(); } public Form1(HttpServiceWatcher serviceWatcher) : this() {...

Why use the key parameter when calling AddComponent on WindsorContainer?

The AddComponent method on the IWindsorContainer interface has several overloads, for example: WindsorContainer.AddComponent<I,T>() and WindsorContainer.AddComponent<I,T>(string key) What's the use of the key parameter and why should I use it? ...

How does Castle Windsor respond to a class which implements multiple interfaces?

For example I have two interfaces: ICustomerService and IOrderService which each has a couple of functions like GetCustomer, GetOrder, etc. I want one class to implement both interfaces: Server. How does Castle Windsor respond to this? Is it possible in the first place? When I resolve the Server object based on one of the two interfac...

Castle Windsor: So what DOES ActAs do?

I noticed that the castle windsor fluent component registration interface has the rather confusing ActAs() method. Googling around for it the only reference I found was at their wiki here. TODO (Stuff that could be documented) what does ActAs() do? Not too helpful. The source doesn't seem to have any unit tests for the...

Castle Windsor: How to prevent circular references in factory-created objects were the created objects refers back to the factory.

I am using windsor castle as my IoC container, and has run in to a bit of a problem. This is best explained in code, so I´ll give it a try. I have a factory class, that should provide me with implementations of a certain interface: public interface IObjectCreatorFactory { IObjectCreator GetObjectCreator(Type objectType); } public in...

Caching in the ASP.NET MVC Framework

I am fairly new at using the ASP.NET MVC framework and was hoping that I could find some help about best-practises when caching various parts of my MVC web application. I know that stack overflow uses MVC and some pretty freeking awesome caching techniques, and its MILES faster than my app, even when running locally. I have a few quest...

Windsor IoC Sample Help - "HttpServiceWatcher& which was not registered."

I'm following the Windsor Inversion of Control (IoC) Getting Started example, which is in C#, but I'm implementing it in VB.Net, and I've run into a small problem.. Here's the exception I'm getting in full: Can't create component 'form.component' as it has dependencies to be satisfied. form.component is waiting for the following ...

How do I use Windsor to inject dependencies into ActionFilterAttributes

Having seen how NInject can do it and AutoFac can do it I'm trying to figure out how to inject dependencies into MVC ActionFilters using Castle Windsor At the moment I'm using an ugly static IoC helper class to resolve dependencies from the constructor code like this: public class MyFilterAttribute : ActionFilterAttribute { priva...

Using DynamicProxy as a decorator pattern in windsor container

I am looking for some info on using and configuring windsor to provide a dynamic proxy to intercept calls to an instance of another class. My class represents a resource that should be retained as a long lived instance by the container for performance reasons. However, sometimes this resource can transition into ununusable state, and...

Action access through Windsor IInterceptor

Im looking to handle authorization in an MVC app through the use of a Windsor IInterceptor - because this seems like the only way I can get named access to parameters the action is passed which are relevant for determining if the user has access. From my Intercept method I need access to the action that is called. I figured out how to ...

Castle Windsor: Will my transient component be garbage collected ?

Using Castle Windsor, I have a component configured with the transient lifestyle: <component id="publish.mapping.default" service="IMyService, MyAssembly" type="MyServiceImplementation, Myassembly" lifestyle="transient" /> Which will be used like this: var service = container.Resolve<IMyService>(componentId); //...

How do i get the the full name of the proxyed type for a nhibernate DynamicProxy?

I am using a netdatacontractserializer and a SerializationBinder to create my own runtime types for nhibernate proxies on the client side. This all works except I am forced to assume that there is only one type by each name in the domain model. i.e. i am forced to ignore the namespace. The reason is that SerializationBinder only gives m...

Castle Windsor: suppress exceptions thrown by Resolve()

When resolving a component which the Windsor container cannot find, an exception is thrown. StructureMap has a TryGetInstance method, which returns null of it can't find the requested component. Does Castle Windsor has something like this? Or am I forced to catch these exceptions (I don't like that, because of the performance overhead ...

Passing empty array of Assemblies to a service in Windsor container

i am using third party library where i need to pass in array of empty assembly. the constructor of the class is: MyService(IEnumerable<Assembly> assemblies) {} in my case the list will be empty. i tried the following with empty value but <component id="service" type="MyService, S" service="IMyService, S"> <parameter...