Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am new to using Castle Windsor I have a couple of registered dependencies using Castle Windsor. I would like to dispose and remove one of these injected dependency at a particular time. How can I do this. My code is as follows: In the main function.
C#
<pre>var container = new WindsorContainer();
 container.Register(Component.For<ILogger>().ImplementedBy<logger>());

Please not that this dependency is not resolved but its Injected using Constructor.
C#
public ILogger logger { get; set; }
 public DoSomethin(
          ILogger logger)
      {
          this.logger = logger;
      }

Please Note that I am using castle windsor V5. The reason for doing this to clear the GC. Older versions have IKernel has a RemoveComponent method. which does not exists nowadays.

What I have tried:

I have tried to use
UsingFactoryMethod().Lifestyle.Transient
Posted
Updated 4-Feb-21 23:43pm

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900