MyTested.AspNetCore.Mvc
MyTested.AspNetCore.Mvc copied to clipboard
UseServiceProviderFactory(new AutofacServiceProviderFactory()) in IsRunning ?
I want to use Autofac in my project but can't add this. If I use the sample in your issues, autofac does not register my generic mediator Handlers, i.e. WithServices(s => s.AddAutofac())
calls ConfigureTestContainer
but somehow Controller throws Handler not Found
exception.
While in my Program.cs, I have:
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
which calls the same
public void ConfigureContainer(ContainerBuilder builder)
{
builder.RegisterGeneric(typeof(Application.Main.Main.Handler<>)).AsImplementedInterfaces();
builder.RegisterGeneric(typeof(Main<,,>.Handler)).AsImplementedInterfaces();
builder.RegisterGeneric(typeof(Main<,>.Handler)).AsImplementedInterfaces();
}
I only renamed it to ConfigureTestContainer
with same lines and invoke base.ConfigureContainer(builder);
, and an error is thrown Only in tests.