volosoft / castle-windsor-ms-adapter

Castle Windsor ASP.NET Core / Microsoft.Extensions.DependencyInjection Adapter
https://www.nuget.org/packages/Castle.Windsor.MsDependencyInjection
MIT License
85 stars 29 forks source link

problems with IConfigureOptions in aspnet core 2 #19

Open maxlego opened 6 years ago

maxlego commented 6 years ago

Can't quite figure out why, but when i upgraded to aspnetcore 2.0 and idnetity 2, authentication options are not configured any more.

Services config lookes like this:

services
    .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
    .AddCookie(o =>
    {
        o.LoginPath = "/login";
        o.LogoutPath = "/logout";
    });

But lamda is not hit.

When i dont return IServiceProvider created by WindsorRegistrationHelper everything works as expected.

jonnii commented 5 years ago

I have run into the same thing with aspnet core 2.2 and the latest version of this package while trying to configure kestrel https... it's very confusing.

jonnii commented 5 years ago

I figured out what this was, we were registering a collection sub resolver before calling startup which meant that the MsCompatibleCollectionResolver was not being called. I'm not entirely sure how to fix this because the ordering of dependencies is (or can be) important for existing code.

jonnii commented 5 years ago

One option would be to only reverse the dependencies for types which live in a Microsoft namespace, this is a hack but works - but it does not deal with someone using the built in collection resolver out of the box, they would need to replace their with the right version.