Skip to content

[Breaking change]: Throw when resolving on a disposed service provider #26783

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

Closed
1 of 2 tasks
maryamariyan opened this issue Nov 2, 2021 · 0 comments · Fixed by #26874
Closed
1 of 2 tasks

[Breaking change]: Throw when resolving on a disposed service provider #26783

maryamariyan opened this issue Nov 2, 2021 · 0 comments · Fixed by #26874
Assignees
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 6 Issues and PRs for the .NET 6 release source incompatible Source code may encounter a breaking change in behavior when targeting the new version.

Comments

@maryamariyan
Copy link
Member

maryamariyan commented Nov 2, 2021

Description

Resolving Services after ServiceProvider is Disposed should throw with ObjectDisposedException.

PR: dotnet/runtime#45116

Version

.NET 6 RC 1

Previous behavior

Prior to the new change, if the application when through the rare case of resolving a service after service provider is disposed, it would lead to deadlock.

New behavior

Rather than deadlock, it will throw ObjectDisposedException.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
  • Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.

Reason for change

To unblock the deadlock scenario.

Recommended action

N/A

Feature area

C#, Core .NET libraries, Extensions

Affected APIs

IServiceProvider GetService or GetRequiredService with Dispose usages in combination.

@maryamariyan maryamariyan added doc-idea breaking-change Indicates a .NET Core breaking change labels Nov 2, 2021
@dotnet-bot dotnet-bot added ⌚ Not Triaged Not triaged 🏁 Release: .NET 6 Issues and PRs for the .NET 6 release source incompatible Source code may encounter a breaking change in behavior when targeting the new version. labels Nov 2, 2021
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 6 Issues and PRs for the .NET 6 release source incompatible Source code may encounter a breaking change in behavior when targeting the new version.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants