简体   繁体   English

使用自动交叉布线时,Simple Injector不包含ASP.NET Core服务

[英]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. 我正在将Simple Injector与ASP.NET Core 2.1配合使用,如下所示启用了自动交叉接线,但是当我执行container.GetCurrentRegistrations()我在Simple Injector容器中看不到任何ASP.NET Core Services。

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. ASP.NET Core注册存在于内置配置系统中,并且仅在注册的应用程序组件依赖于ASP.NET Core组件的情况下才链接到Simple Injector。 Auto Cross-Wiring does not copy all ASP.NET Core registrations. 自动交叉布线不会复制所有ASP.NET Core注册。

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. 如果您想知道ASP.NET Core内部包含什么内容,则必须深入研究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. 如果您想知道您在Simple Injector中注册了哪些应用程序组件,则可以使用Simple Injector的调试器视图来进行操作,或者像当前一样调用GetCurrentRegistrations

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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