Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 54443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:13:15+00:00 2026-05-10T17:13:15+00:00

I have an object that implements IDisposable that is registered with the Windsor Container

  • 0

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.Release(obj); 

Couldn’t find anything in the documentation on what exactly Release does

EDIT: See my answer below for the results of tests I ran. Now the question becomes, how do I force the container to release an instance of a component with a singleton lifecycle? This only needs to be done in one place and writing a custom lifecycle seems far too heavyweight, is there no built in way of doing it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:13:16+00:00Added an answer on May 10, 2026 at 5:13 pm

    This is something I think people aren’t really aware of when working with the Windsor container – especially the often surprising behavior that disposable transient components are held onto by the container for the lifetime of the kernel until it’s disposed unless you release them yourself – though it is documented – take a look here – but to quickly quote:

    the MicroKernel has a pluggable release policy that can hook up and implement some routing to dispose the components. The MicroKernel comes with three IReleasePolicy implementations:

    • AllComponentsReleasePolicy: track all components to enforce correct disposal upon the MicroKernel instance disposal
    • LifecycledComponentsReleasePolicy: only track components that have a decommission lifecycle associated
    • NoTrackingReleasePolicy: does not perform any tracking

    You can also implement your own release policy by using the interface IReleasePolicy.

    What you might find easier is to change the policy to a NoTrackingReleasePolicy and then handle the disposing yourself – this is potentially risky as well, but if your lifestyles are largely transient (or if when your container is disposed your application is about to close anyway) it’s probably not a big deal. Remember however that any components which have already been injected with the singleton will hold a reference, so you could end up causing problems trying to "refresh" your singletons – it seems like a bad practice, and I wonder if perhaps you can avoid having to do this in the first place by improving the way your applications put together.

    Other approaches are to build a custom lifecycle with it’s own decommission implementation (so releasing the singleton would actually dispose of the component, much like the transient lifecycle does).

    Alternatively another approach is to have a decorator for your service registered in the container with a singleton lifestyle, but your actual underlying service registered in the container with a transient lifestyle – then when you need to refresh the component just dispose of the transient underlying component held by the decorator and replace it with a freshly resolved instance (resolve it using the components key, rather then the service, to avoid getting the decorator) – this avoids issues with other singleton services (which aren’t being "refreshed") from holding onto stale services which have been disposed of making them unusable, but does require a bit of casting etc. to make it work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Use the ob_get_level() function to see if an output buffer… May 11, 2026 at 11:13 am
  • added an answer What does he use -- std::string only? Does he know… May 11, 2026 at 11:13 am
  • added an answer Sure thing! Grouping and references are your friends: (.)\1+ Will… May 11, 2026 at 11:13 am

Related Questions

I have an object that implements IDisposable that is registered with the Windsor Container
I have an object that implements ArrayAccess , Iterator and Countable . That produces
I have an object that is mapped to a cookie as a serialized base-64
I have an object that needs a test if the object data is valid.
I have an object that starts a thread, opens a file, and waits for
I have an object that can build itself from an XML string, and write
I have an object that has a list of abstract 'aninamls'. i.e. var animals
I have an object that is generated in one class public class CreatingClass {
I have an object that is mapped to have a set of objects, very
I am using an asp:Calander and I have an object that has a beginning

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.