I'm building a console app and I decide to use Autofac following the example detailed here.
So I:
Registered the Autofac Service Provider
...
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
...
Registerd the IHttpClientFactory:
containerBuilder
.Register(ctx => ctx.Resolve<IHttpClientFactory>().CreateClient())
.As<HttpClient>();
Registered all the other services, in particular:
containerBuilder.RegisterType<UpdaterServiceClient>().As<IUpdaterServiceClient>();
The UpdaterServiceClient has a constructor like this:
public UpdaterServiceClient(SBMOptions sbmOptions, IHttpClientFactory httpClientFactory, ILogger<UpdaterServiceClient> logger)
The exception I obtain is:
Type: Autofac.Core.DependencyResolutionException Message: An exception was thrown while activating UpdaterServiceClient. Type: Autofac.Core.DependencyResolutionException Message: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'UpdaterServiceClient' can be invoked with the available services and parameters: Cannot resolve parameter 'System.Net.Http.IHttpClientFactory httpClientFactory' of constructor 'Void .ctor(SBMOptions, System.Net.Http.IHttpClientFactory, Microsoft.Extensions.Logging.ILogger`1[UpdaterServiceClient])'.
Any suggestions as to what may be causing the issue