ServiceProvider not providing registered service [Answered]
For some reason, despite registering this api wrapper as so:
Attempting to retrieve it from the service provider results in an InvalidOperationException because the type is not in the service provider. This happens whether I request the interface or the concrete implementation. Rider does in fact confirm that the scoped rest api wrapper is present in the service collection when stepping through.


12 Replies
In the screeshotted sample above, I changed
GetRequiredService()
to GetService()
to avoid the throw since I'm using a result mechanism, but as you can see it hits the return Result.FromError()
line because the returned service instance is null.how are you retrieving it from the service provider?
you are retrieving the
IInContactRestAPI
, right?
be sure to create a scope
You know what, that might be it entirely. I don't know if the plugin service creates a scope per plugin
you need to do
typed that without intellisense so I don't know if it's correct

Looks like it's happy now
😁
async scope, fancy
I'll add that as an issue to the plugin library I think. Plugins should have their own scopes.
You can /close it if it all works ^^
✅ This post has been marked as answered!