Closed rossdargan closed 5 years ago
You need to use the ConfigureContainer approach instead of returning the IServiceProvider from ConfigureServices. That style of doing custom DI is going away in 3.0. Do this instead https://github.com/structuremap/StructureMap.Microsoft.DependencyInjection#example
@javiercn can we mark this as deprecated in 3.0?
No more changes planned here.
I'm using structure map which means I have to configure my
ConfigureServices
method to return aIServiceProvider
as per the example here: https://github.com/structuremap/StructureMap.Microsoft.DependencyInjection#example-1.ConfigureTestServices registers a
IStartupConfigureServicesFilter
which results in the following exception:A ConfigureServices method that returns an IServiceProvider is not compatible with the use of one or more IStartupConfigureServicesFilter. Use a void returning ConfigureServices method instead or a ConfigureContainer method.
This is thrown here: https://github.com/aspnet/Hosting/blob/cfe9b26a34af15c4943240d790ee5d1a168290c9/src/Microsoft.AspNetCore.Hosting/Internal/StartupLoader.cs#L185
I'm trying to register a test authentication schema which as far as I can tell should be done via ConfigureTestServices, but I'm using structuremap so I'm not sure how else I can go about this. My customer app factory looks like this:
}
Is there any way to achieve this without putting some testing code in my primary website (the SUT)?