views:

55

answers:

1

I am using wcf 4 and trying to use some Ioc container to resolve service dependencies. I was looking at Castle Windsor and StructureMap. I haven't use any of them with wcf.

The scenario is that I have IService1 and Iservice2. Service1 is using service2:

public class Service1 : IService1
{
    public Service1(IService2 service2)
    {

    }
}

If I use WcfFacility from Castle with a transient lifecycle for service2 will it automatically dispose service2 after service1 is done with it(consider service1 a per-call instantiation for example)? And how exactly does that work internally. How is this done with structuremap?

Some sample code would be really appreciated.

A: 

Yes, Windsor will do that for you out of the box. It's the default, you don't have to do anything. It tracks all disposable objects and their dependencies it creates and then disposes them as needed. Google "component burden" if you want the details.

Krzysztof Koźmic
thanks for that, it seems Castle is the choice, I can't find the facility in the released binaries though. Do I have to compile it myself?
Cosmin Onea
yep, it is not yet released, although it's rather bug free - it's been used in production
Krzysztof Koźmic