C
C#2y ago
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.
34 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
I've been looking at the different DI. Transient - It's created everytime it's requested, If I'm not wrong 😛
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
One instanse created?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
Within it's scope? 😛
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
Yup
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
Yup
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
Yupp, still ok
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
In the constructor?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
Everytime the class is called?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
Once during the lifetime of the application
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
D:
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
Ops xD
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
Yes, makes sense so far
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
HostedService?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
Singleton?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
Hmm
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
julian
julianOP2y ago
That makes more sense 😛 Trying to fix the issue now, will get back to you! Thanks for now @TeBeClone 🙂
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server