Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent disposing cross-wired dependencies #683

dotnetjunkie opened this Issue Apr 15, 2019 · 0 comments


None yet
1 participant
Copy link

dotnetjunkie commented Apr 15, 2019

The Simple Injector integration packages allows cross wiring of services provided by the ASP.NET Core configuration system. In doing so, however, it partly takes control and ensures disposal. The Core configuration system, unfortunately, disposes those components as well, causing a dependency to be disposed twice.

Due to the definition of the dispose pattern, this shouldn't be a problem. Classes must allow Dispose to be called multiple times without causing problems.

Developers, however, don't always work according to this pattern, and this might cause performance issues as dispose is called twice.

Since Simple Injector can not tak ownership of those components, it should let Core dispose of these instances (as there is no way to instruct Core to not dispose of those instances anyway) and prevent disposing them.

This does mean, however, introducing a change to the Simple Injector core library as it does not allow disabling the disposal of Scoped or Singleton components (this is a feature that had been removed with the introduction of v3.0).

@dotnetjunkie dotnetjunkie added this to the Backlog milestone Apr 15, 2019

@dotnetjunkie dotnetjunkie modified the milestones: Backlog, v4.6 Apr 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.