Skip to content

How to register an IDisposable instance that should outlive the container? #595

Description

@roy-t

Short question that I couldn't find in the docs.

I have an instance of an object that implements IDisposable. Let's name it foo. When I use container.RegisterInstance<T>(foo) foo will, from then on, be owned by the container. When I call container.Dispose() foo will be disposed as well.

Is there a way to make sure foo outlives the container? Since it wasn't created by LightInject I also don't want LightInject to clean it up.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions