我发现/在我的一个程序集中添加了 scrutor 来测试它。我评论了原始注册并添加了扫描语句:
public static IServiceCollection AddTestThing(this IServiceCollection services
, IConfiguration configuration) {
// services.AddTransient<IExampleService, ExampleService>();
// services.AddTransient<IA_B, A_B>();
// services.AddTransient<IA_C, A_C>();
// services.AddTransient<ID_A, D_A>();
services.Scan(scan => scan
.FromExecutingAssembly()
.AddClasses()
.UsingRegistrationStrategy(RegistrationStrategy.Skip)
.AsImplementedInterfaces()
.WithTransientLifetime());
return services;
}
但它似乎什么也没做。在调试期间,它立即说服务未注册。所以我显然错过了一些东西。当我调试和查看服务时,我也看不到任何添加的服务。