8000 Is it possible to recommend a different approach or improve on this one? · Issue #46061 · dotnet/docs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Is it possible to recommend a different approach or improve on this one? #46061

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

Open
emardini opened this issue May 9, 2025 · 0 comments
Open

Comments

@emardini
Copy link
emardini commented May 9, 2025

Type of issue

Typo

Description

While injecting a service factory or service provider could overcome the issue of injecting scoped dependencies into a background job, it can create problems, for example, the service call could blow up during the execution due to a misconfiguration and not during the construction which is what we want our DI to do, the recommendation in this documentation while works may bring its own set of problems.

I wonder if instead of doing this, we can simply register the same dependency twice: one as a singleton and another one as scoped, the DI will pick the most suited for each case.

Which problems do you see with this approach? At worst, it could be wortwhile to discuss the pitfalls of injecting a service locator, for example, checking for errors while trying to locate the dependency.

Page URL

https://learn.microsoft.com/en-us/dotnet/core/extensions/scoped-service

Content source URL

https://github.com/dotnet/docs/blob/main/docs/core/extensions/scoped-service.md

Document Version Independent Id

5a2fc6e8-a47b-c300-1ef0-e6ae89612d74

Platform Id

a6310155-bcdf-f5b9-b058-c635e4438048

Article author

@IEvangelist

Metadata

  • ID: ca143da3-5c97-0dc0-9d99-ed477a8bce91
  • PlatformId: a6310155-bcdf-f5b9-b058-c635e4438048
  • Service: dotnet-fundamentals

Related Issues

@dotnet-policy-service dotnet-policy-service bot added the ⌚ Not Triaged Not triaged label May 9, 2025
@emardini emardini changed the title Is it possible to recommend a different approach Is it possible to recommend a different approach or improve on this one? May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0