1
votes

I'm using Castle Windsor with my WCF service (hosted using console application).

This is my configuration:

 container.AddFacility<WcfFacility>().
           Register(Component.For<IService>().
           ImplementedBy<MyService>().LifeStyle.Transient.
           AsWcfService(new DefaultServiceModel().
           AddBaseAddresses("someURI").
           AddEndpoints(WcfEndpoint.BoundTo(new BasicHttpBinding())).
           PublishMetadata(o => o.EnableHttpGet())));

I chose Transient lifestyle for my service and some of this service dependencies are also Transients. As I understand after reading the documentation and some blogs if you have component with lifestyle Transient you should be responsible for releasing it.

  1. Where should I release my transient component? Is this my responsibility or maybe the WcfFacility take care for that somehow?

  2. What is the difference between Transient and PerWcfSession lifestyle (btw what is the different between PerWcfSession and PerWcfOperation isnt each operation called on WCF service have its own session?)

1

1 Answers

1
votes
  1. You have the responsibility to release any component that you resolve directly from the container. So you never release subdependencies of a component that you resolve.

Since in this case the wcf service is resolved for you by the facicility, you don't need to release anything. The facility will take care.

  1. If you register as PerWcfCall you will get one component per wcf call. If you use transient than everytime you have a subdependency of that type you will get a new instance.