Repository navigation
AddHostedService does not register specified Type Parameter in DI container #53831
Copy link
Copy link
Closed
Closed
Copy link
Labels
area-Extensions-HostingdocumentationDocumentation bug or enhancement, does not impact product or test codeDocumentation bug or enhancement, does not impact product or test codein-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
Activity
- ghost addeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Jun 7, 2021 - removeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Jun 19, 2021 - addedbacklog-cleanup-candidateAn inactive issue that has been marked for automated closure.An inactive issue that has been marked for automated closure.
on Jan 20, 2026 This is a human generated activity to keep it alive 😃
- removedbacklog-cleanup-candidateAn inactive issue that has been marked for automated closure.An inactive issue that has been marked for automated closure.
on Jan 20, 2026 Triage: Given lower interest (2 people in 5 years) + there is simple workaround, we do not think we should add new API -- that is an overkill for a niche scenario.
We could improve documentaiton. @cincuranet will look at it.Reacted by T. Thiery- addeddocumentationDocumentation bug or enhancement, does not impact product or test codeDocumentation bug or enhancement, does not impact product or test code
on Jan 21, 2026 - addedin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
on Jan 27, 2026 - added a commit that references this issue
on Jan 30, 2026 - added a commit that references this issue
on Mar 2, 2026 - locked and limited conversation to collaborators
on Mar 28, 2026
Metadata
Metadata
Assignees
Labels
area-Extensions-HostingdocumentationDocumentation bug or enhancement, does not impact product or test codeDocumentation bug or enhancement, does not impact product or test codein-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Description
The issue is quite straight forward in the .NET source code because the
THostedServiceis not registered but instead aIHostedService...The common workaround seems to be like
My expectation was clearly, that the type I register with a
ServiceCollection.Add*function later can be retrieved. I lost several hours due to this until I found the answer somewhere on StackOverflow.Configuration
Regression?
No
Other information
If the vote is not to double register the service (I assume the
IHostedServiceis needed for the host logic), I would at least propose to add a warning in the documentation and maybe the function inline documentation.