❔ SignalR .NET 7 API Dependency injection not working
Hello. As I have described here https://github.com/dotnet/aspnetcore/issues/46095#issuecomment-1587264717 with a trivial example, I cannot manage to make Dependency injection work with SignalR. Been trying so for days. Any help would be appreciated.
4 Replies
I don't see how the instantiation order affects anything
you probably have a lifetime mismatch issue here
in the thread you're responding to, the issue is that the developer is putting logic inside of constructors, and thus has issues when the constructors don't run in a particular order
you're not doing this
if _userInfo in your repository doesn't have the right info, it's cause it never got populated
either the code that populates it isn't running, or its running on a different instance
Hey thanks for answer. Yeah I guess I've given a wrong example. Thats exactly what I'm doing, extracting the tenant data in the constructor.
Here's the fixed code
as in, you fixed the fact that you weren't showing your actual code?
cause
that's not a fix
that's specifically the thing you shouldn't do
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.