Questions tagged [autofac-configuration]
88 questions
1
vote
1 answer
Adding Autofac JSON configuration to .NET core 6.0 using the new single file template
I am trying to add Autofac to a .NET 6.0 web API and read Autofac components configuration from a JSON file.
I'm using the latest ASP.NET Core Web API template that generates a single start-up Program.cs file.
Installed Autofac…

sorosh_sabz
- 2,356
- 2
- 32
- 53
1
vote
1 answer
How to Resolve ILogger in Autofac container
I am trying to replace dryIOC container with autofac container for some reason but I don't know the exact syntax how could I resolve ILogger uisng autofac
Here is how I register ILogger in DryIoc
public void Load(IContainer container)
{
…

Marcelll
- 25
- 3
1
vote
1 answer
Is it possible to make Autofac fail if there are multiple singleinstance-registrations for a single interface?
When multiple single-instances are registered for a single interface, it seems that Autofac's default behavior is to let them overwrite each other, such that latest registration is the one that'll be used to build the container. Is there anyway to…

Søren Breinholm
- 11
- 2
1
vote
1 answer
Autofac - How to access IRegistrationBuilder from IResolvePipelineBuilder & ResolveRequestContext?
I would like to extend my service registration [e.g. EnableInterfaceInterceptors] from Autofac Pipeline. However, I couldn't find a way to achieve that. Is there any entrypoint for me to access the registration as IRegistrationBuilder?
Provided…

mannok
- 1,712
- 1
- 20
- 30
1
vote
0 answers
Measure and monitor Autofac resolve time of individual components
There is reply for the same question here but that is for old Autofac:
How to measure and monitor Autofac resolve time of individual components
New version of Autofac is not exposing Preparing & Activating method any more.
Can some one please help…

Saurav Bandyopadhyay
- 11
- 2
1
vote
1 answer
Singleton BackgroundService not started by Autofac
I am running Autofac.Extensions.DependencyInjection 7.1.0 in an ASP.NET Core 3.1 REST API.
I have a BackgroundService class and configured to run as a SingleInstance.
My problem is that the StartAsync is never called. But configured without the…

ToPa
- 363
- 3
- 7
1
vote
2 answers
Configure Autofac DI container in ASP.NET CORE 3.1 Web API and consumer service from controller
I need to configure Autofac DI container in ASP.NET CORE 3.1 Web API application and call register class from the container in Web API controller. I install Autofac.Extensions.DependencyInjection (6.0.0) and try to register container in my…

K.Z
- 5,201
- 25
- 104
- 240
1
vote
2 answers
Autofac ApiController Filters For Methods With Attribute
The goal is to convert a handful of Attr into DI filter from Autofac using .AsWebApiAuthorizationFilterFor(c => c.GetType()
Feel like I am close but prob just doing it wrong, found a bunch of posts about peram injector but that is not…

workabyte
- 3,496
- 2
- 27
- 35
1
vote
1 answer
Injection in web api controller not using Single Instance
I have a service that is registered in my container as a single instance
public class MyModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType()
.As()
…

Paul
- 2,773
- 7
- 41
- 96
1
vote
1 answer
Two implementations of the same interface in Autofac's JSON configuration
I need to enable late-binding in an application and I want to have an option to explicitly configure services using JSON configuration file.
I have an interface IDependency and two classes DependencyOne and DependencyTwo which both implement the…

Piotr
- 572
- 5
- 22
1
vote
3 answers
Unable to do property injection using Autofac
I am new to autofac. I am trying to do property injection using this IoC container. The following is my code. I am getting error:
Object reference not set to an instance of an object
At this line: .
return _salary.employeeSalary; in the…

Massey
- 1,099
- 3
- 24
- 50
1
vote
1 answer
How can I use some of my services and repositories in job class of Quartz.net?
I need to use some of my services in job class of Quartz.net
I use Autofac as dependency injection
public class PushJob : IJob
{
public async Task Execute(IJobExecutionContext context)
{
// need to use some…

Ali Tanha
- 13
- 5
1
vote
0 answers
Autofac Dependency Injection - Set public property
I am building the asp.net WebAPI project and have used Autofac as IOC. Now i am doing constructor based injection and calls the various methods of the business class from the controller class.
Now i want to pass some additional data into the…

Karan
- 3,265
- 9
- 54
- 82
1
vote
1 answer
autofac not resolve properly generic List type
I am trying to resolve list of object using autofac Container, and expecting an empty list in response. However, I am not able to get empty list in return instead getting count as 1.
I also try with without list registration in aotufac conatiner but…

Vipin Mishra
- 11
- 2
1
vote
1 answer
Bot Framework AutoFac Dependency Issue C# (Multiple Container)
In my app start I have the following code to register my module.
Conversation.UpdateContainer(builder =>
{
builder.RegisterModule();
});
And I am using InstrumentedLUIS which has the following…
user9430316