Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UseServiceProviderFactory(new AutofacServiceProviderFactory()) in IsRunning ? #404

Open
amunim opened this issue Feb 1, 2022 · 0 comments
Assignees
Labels

Comments

@amunim
Copy link

amunim commented Feb 1, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants