Closed davidkeaveny closed 3 years ago
I also just found that if I replaced the ILoginService
dependency with an IServiceProvider
then called (ILoginService)serviceProvider.GetService(typeof(ILoginService))
in my AuthenticationQueryHandler
then the dependency would also fail to be resolved correctly; if I tried to resolve the explicit type then it works again, which I guess is a sort of work-around, but it's a bit of an anti-pattern.
So the issue appears to be that the dependency is not resolving properly when attempting to resolve the interface, but will resolve the type.
Hi @davidkeaveny
That doesn't make much sense to me, I also agree passing in the IServiceProvider
is not a good solution. Can you run call what do I have on the container after you've finished registering to see what's exported in the container?
Where did you end up on this?
Sorry, I ended up switching to Autofac for this one, I was on a tight deadline.
I’m going to close this out without a project to reproduce it
Hi there,
I'm using Grace 7.1.1 with an ASP.NET Core 3.1 Web API, and am having a very weird problem with one specific dependency resolution that I hope someone can help with.
The API is resolving the following dependency:
The registrations are as follows:
When I try to resolve the
AuthenticationQueryHandler
usingIQueryHandler<AuthenticationQuery, AuthenticationResult>
then I get aLocateException
on thelogins
parameter, saying that theILoginService
cannot be located. If I try to resolve theAuthenticationQueryHandler
usingAuthenticationQueryHandler
then it resolves correctly. If I try to resolveILoginService
then it also resolves correctly, although it is also listed in thePossibleMissingDependencies
.Other implementations of
IQueryHandler<,>
resolve fine, so the registration process seems to be working okay.