LightInject icon indicating copy to clipboard operation
LightInject copied to clipboard

Wrong type resolving on version 1.6.0 and 1.6.1

Open yevgenchepurko opened this issue 1 year ago • 2 comments

Dear, Bernhard Richter.

Thank you for your work on LightInject.Microsoft.Hosting and other components. Here is an issue that we've encountered with LightInject.Microsoft.Hosting.

With version 1.5.3

having setup

serviceRegistry.RegisterScoped<IA>(f => new A1());
serviceRegistry.RegisterScoped<IA>(f => new A3(), nameof(A3));
serviceRegistry.RegisterScoped<IA>(f => new A2(), nameof(A2));

the resolution

host.Services.GetService<IA>();

Resolved to Type A1 - unnamed instance. But with latest version 1.6.1 it resolves into A3, it started with version 1.6.0

Please find attached test project demonstrating the issue. LightInjectMicrosoftHostingTest.zip

yevgenchepurko avatar Oct 04 '24 07:10 yevgenchepurko

1.6.0 and 1.6.1 are just broken, 2.x should contain a fix.

kemsky avatar Nov 27 '24 20:11 kemsky

@yevgenchepurko See if you can upgrade to 2.1.0 and see if that solves your issue

seesharper avatar Nov 27 '24 22:11 seesharper