castle-windsor

How to get the libraries you need into the bin folder when using IoC/DI

I'm using Castle Windsor to do some dependency injection, specifically I've abstracted the DAL layer to interfaces that are now being loaded by DI. Once the project is developed & deployed all the .bin files will be in the same location, but for while I'm developing in Visual Studio, the only ways I can see of getting the dependency inj...

Applying AOP

I've been using some basic AOP style solutions for cross-cutting concerns like security, logging, validation, etc. My solution has envolved around Castle Windsor and DynamicProxy. I've gone down this route because I can apply everything using a Boo based DSL and keep my code clean of Attributes. I was told at the weekend to have a loo...

Castle Windsor: How do you add a call to a factory facility not in xml?

I know how to tell Castle Windsor to resolve a reference from a factory's method using XML, but can I do it programmatically via the Container.AddComponent() interface? If not is there any other way to do it from code? EDIT: There seems to be some confusion so let me clarify, I am looking for a way to do the following in code: <facil...

Windsor Container: How to force dispose of an object?

I have an object that implements IDisposable that is registered with the Windsor Container and I would like to dispose of it so it's Dispose method is called and next time Resolve is called it fetches a new instance. Does container.Release(obj); automatically call Dispose() immediately? Or do I need to do obj.Dispose(); container....

Castle Windsor: How to specify a constructor paramter from code?

Say I have the following class MyComponent : IMyComponent { public MyComponent(int start_at) {...} } I can register an instance of it with castle windsor via xml as follows <component id="sample" service="NS.IMyComponent, WindsorSample" type="NS.MyComponent, WindsorSample"> <parameters> <start_at>1</start_at > </para...

Can you register an existing instance of a type in the Windsor Container?

In the Windsor IOC container is it possible to register a type that I've already got an instance for, instead of having the container create it? ...

Windsor Container: Registering things in Code vs Xml

From what I've read about Windsor/Microkernel it is in theory possible to do everything that you can do using xml files with code. As a matter of fact - and please correct me if I'm wrong - it seems like the major contribution of the Windsor layer is to add xml configuration for things Microkernel can already do. However, I have been ...

Windsor Interceptors AOP & Caching

I'm considering using Castle Windsor's Interceptors to cache data for helping scale an asp.net site. Does anyone have any thoughts/experience with doing this? Minor clarification: My intention was to use Windsor to intercept 'expensive' calls and delegate to MemCacheD or Velocity (or another distributed cache) for the caching itself. ...

How do I do Dependency Injection in a test project (TFS 2008) using Castle

I'm using Castle Windsor for dependency injection in my test project. I'm trying to create an instance one of my 'Repository' classes. "It works fine on my machine", but when I run a nightly build in TFS, my tests are not able to load said classes. private static readonly WindsorContainer _container = new WindsorContainer(new XmlInterpr...

IoC, Where do you put the container?

I'm using castle windsor for a pet-project I'm working on. I'm starting to notice that I need to call the IoC container in different places in my code to create new objects. This dependency on the container makes my code harder to maintain. There are two solutions I've used to solve this problem I tried to create abstract factories as ...

Where can I find an .xsd file to provide intellisense for Castle Windsor?

I'm looking for an .xsd schema file to drop into my Visual Studio directory to provide intellisense for the xml configuration file for the Castle Windsor IoC container. I've looked in the downloaded code for Windsor, as well as googled several different ways. I see many people asking the same question, but no answers. Anyone know if ther...

How do I get access to Castle Windsor's Fluent Interfaces API?

I've been having tons of problems getting the non-xml configuration for Castle Windsor set up working properly. In the meantime I've seen more and more people giving advice via the Windsor Container fluent interface. I've been Gooogling about for the last day and I cannot find this API anywhere. I am talking about the key .Register() ...

What is Castle Windsor, and why should I care?

I'm a long-time Windows developer, having cut my teeth on win32 and early COM. I've been working with .Net since 2001, so I'm pretty fluent in C# and the CLR. I'd never heard of Castle Windsor until I started participating in Stack Overflow. I've read the Castle Windsor "Getting Started" guide, but it's not clicking. Teach this old d...

Why does Castle Windsor hold onto transient objects?

Recently I noticed my application appears to be eating memory that never gets released. After profiling with CLRProfiler I've found that the Castle Windsor container I'm using is holding onto objects. These objects are declared with the lifestyle="transient" attribute in the config xml. I've found if I put an explicit call to IWindsorCo...

Castle-Windsor swapping service at runtime

Let say we defined an interface for tax service as ITaxService, and we got more than one implementation of TaxService (by region) however I wanted to attach a specific tax implementation to a specific customer from the spcific region. Will DI help in this scenario? How? "code snippet would be much appreciate" ...

Binsor and log4net

I'm using Castle Windsor and Binsor to use dependency injection in my application. I'm no expert at either one. Usually I can figure out how to bend Windsor to my will, but I find Binsor much harder, especially since I haven't found any decent documentation for it. I'm trying to create a binsor configuration file where I use logging. I ...

How do you pass an object to a windsor container instead of a type?

I have the following class: public class ViewPage<TView,TPresenter> : Page where TView : IView where TPresenter : Presenter<TView> { public ViewPage() { if (!(this is TView)) throw new Exception(String.Format("The view must be of type {0}", typeof(TView))); IWindsorContainer container = new WindsorContainer(); container.A...

Which Dependency Injection Tool Should I Use?

I am thinking about using Microsoft Unity for my Dependency Injection tool in our User Interface. Our Middle Tier already uses Castle Windsor, but I am thinking I should stick with Microsoft. Does anyone have any thoughts about what the best Dependency Injection tool is? Autofac Castle MicroKernel/Windsor ObjectBuilder PicoContainer...

Windsor Container: How to specify a public property should not be filled by the container?

When Instantiating a class, Windsor by default treats all public properties of the class as optional dependencies and tries to satisfy them. In my case, this creates a rather complicated circular dependency which causes my application to hang. How can I explicitly tell Castle Windsor that it should not be trying to satisfy a public p...

Windsor Container and internal properties

Is there any solution how to initialize properties of component marked as 'internal'? What assembly name should I use for InternalsVisibleTo attrribute or it won't help? ...