© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
95 replies
julian

✅ Scoped, Singleton and HostedService

Any .NET Masters here? xD

Issue:
I'm trying to create a new Background Service for automatic selling/buying crypto (It's a school project, so no real trading/money involved).
I'm having issues with the activation of the repo/services etc.

I'm adding the Repo to my Service, which has EF Core (Repo).
It has Scoped on the Repository classes.

When I try to add the Service as a Singleton and my background service as a HostedService, I just get an error that It can not activate.

I'm using ASP.NET Core Web API

Any work arounds?

I've tried posting in the DotNetEvolution, but didn't get any response.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

HostedService stopping infinitely
C#CC# / help
2y ago
How do I manage singleton Regex initialization in Scoped service ?
C#CC# / help
2y ago
Managing Scoped Service Lifecycles with a Singleton Factory in .NET: Best Practices?
C#CC# / help
17mo ago
✅ Singleton Class
C#CC# / help
3y ago