简体   繁体   中英

Simple Injector doesn't contain ASP.NET Core services when using Auto Cross-Wiring

I am using Simple Injector with ASP.NET Core 2.1 I have enabled auto cross wiring as shown below but when I do container.GetCurrentRegistrations() I don't see any ASP.NET Core Services available in Simple Injector container.

container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();

services.AddHttpContextAccessor>();
services.AddSingleton<IControllerActivator>(
    new SimpleInjectorControllerActivator(container));

services.EnableSimpleInjectorCrossWiring(container);
services.UseSimpleInjectorAspNetRequestScoping(container);

Please suggest what could be the issue?

ASP.NET Core registrations live in the built-in configuration system and only get linked to Simple Injector in case a registered application component depends on an ASP.NET Core component. Auto Cross-Wiring does not copy all ASP.NET Core registrations.

So to be clear, there is no issue here. If you want to know what lives inside ASP.NET Core, you will have to drill into the ServiceCollection. If you want to know what application components you registered inside Simple Injector, you can use Simple Injector's debugger view to do so, or call GetCurrentRegistrations as you are doing currently.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM