-
-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolving services registered as open generics with generic constraints throws ComponentNotRegisteredException #972
Comments
I've added a failing unit test and traced this down as being in In I'm curious if, in general, there's a better way to figure out through reflection if a given concrete type fulfills an open generic's constraints. If so, it would be better to employ something more robust. I've soaked up all my time for the day drilling down into this to locate the problem; I won't be able to fix it immediately. If others have a fix/PR, I'm open to that. |
This gets fixed by #978. Yay! |
I think this change broke Entity Framework Core DI registrations. Another change in the 4.9.3 release broke the app initially because of a duplicate registration that was mistakenly in the application. When I resolved that issue, there is now an error getting a DbContext. The registrations for DbContext are supposed to be handled by framework so I am not sure if this is an issue with something I am doing, Microsoft is doing, or an issue in this change. Curious if anyone else is encountering this, here is stack trace from my application:
|
@danjohnso If you would, please open a new issue and include a repro that shows us how to see this happen. Unfortunately a stack trace is not enough to determine if this change is related or not, or to try to debug what you're seeing. Thanks! |
This change does seem to have introduced a new problem. While I could open another issue (and it could relate to the issue that @danjohnso has raised), I'm pretty sure it is closely related to this one. The repro code given in the initial issue description shows the problem. Now, the line after the comment "This would throw ComponentNotRegisteredException" no longer throws, which I understand was the objective. However, the line after the comment "This would resolve nicely" does throw an exception (so, of course, you have to remove it or step over it to get to the working line). I don't believe that the intent was for that line to no longer resolve the registration, was it? The exception is a different one:
|
Possibly related to #688.
Whenever registered open generic has another generic class or interface reference in its type constraint, service resolution fails with ComponentNotRegisteredException error.
Code to reproduce:
Exception details:
Environment:
The text was updated successfully, but these errors were encountered: