Questions tagged [autofac-module]
82 questions
11
votes
2 answers
Net Core: access to appsettings.json values from Autofac Module
AspNet core app
1) Autofac module like that
public class AutofacModule : Module
{
protected override void Load(ContainerBuilder builder)
{
//Register my components. Need to access to appsettings.json values from here
}
}
2)…

Frank59
- 3,141
- 4
- 31
- 53
9
votes
2 answers
Autofac Modules in N-Tier Architecture
Currently I'm using Autofac for IoC and at two composition roots (one for the front-end and one for the back-end) I register and resolve the components spanned across Service, Business and Data layers.
As of now I have a single one like…

Mohsen Afshin
- 13,273
- 10
- 65
- 90
6
votes
1 answer
How to configure MassTransit with Autofac Module?
I'm trying to setup MassTransit with Autofac (latest NuGet packages) but it seems that consumers cannot be registered at the ContainerBuilder level.
Has anyone managed to use MassTransit with Autofac, especially with modules?
In the sample below,…

winromulus
- 469
- 4
- 5
6
votes
4 answers
Should Autofac modules register their own dependent modules?
Consider I have an app that uses three libraries, lib1, lib2 and lib3. In each of the libraries I have implemented a Module that registers the dependencies that are implemented in that library.
Some of these implementations have their own…

Dave Van den Eynde
- 17,020
- 7
- 59
- 90
5
votes
2 answers
How to use AutoFac with .NET MAUI
A few years ago I created a suite of nuget packages that I use for CQRS which use AutoFac modules to wire up the internals. I'd like to use that in my .NET MAUI development so I've updated them to .NET 6.0 and they link in with my MAUI project…

Stephen York
- 1,247
- 1
- 13
- 42
5
votes
1 answer
Autofac Enumeration not working with multiple registrations of types or modules
The autofac documentation states:
when Autofac is injecting a constructor parameter of type IEnumerable it will not look for a component that supplies IEnumerable. Instead, the container will find all implementations of ITask and…

jeromerg
- 2,997
- 2
- 26
- 36
4
votes
1 answer
Autofac module registrations
I have mostly used Ninject, so I apologize if I mix up terminology.
I created a logger module to handle NLog using the destination class name as the logger name. It is very similar to this:…

Dan
- 1,101
- 1
- 9
- 30
4
votes
0 answers
Autofac - SingleInstance across multiple containers
I have an application that dynamically starts different processes.
Each one of that processes consumes an autofac CoreModule, and each one has his own Module for that very process.
CoreModule defines a few components that must be SingleInstance…

Martin Solovey
- 41
- 3
3
votes
1 answer
None of the constructors found can be invoked with the available services and parameters Autofac
I have read and coding follow example: http://timschreiber.com/2015/01/14/persistence-ignorant-asp-net-identity-with-patterns-part-1/
But that example used Unity for DI, but i'm used Autofac for ID, when i try run my project i have the following…

Trường Sơn
- 83
- 1
- 5
3
votes
2 answers
How to make the connection string available in a N-Tier ASP.NET MVC Core 1.0 App with Autofac
I wired the layer together via autofac modules. Big thanks to endeffects. Here is the HowTo. Now I'm trying to make the connection string available in the DAL layer. I tried to register the:
Configuration (Microsoft.Extensions.Configuration)
From…

stevo
- 2,164
- 4
- 23
- 33
2
votes
1 answer
Autofac log4net middleware example does not seem to work
I am trying to start using middleware and creating a logger for a project and thought the autofac log4net example was a good starting point as the project already is making use of autofac, but I am not being able to do so. I have the following…

elgato
- 506
- 1
- 5
- 20
2
votes
1 answer
Autofac RegisterAssemblyTypes from tests
In my Startup class I a have method for RegisterAssemblyTypes through autofac as the following:
public class Startup
{
public void ConfigureContainer(ContainerBuilder builder)
{
builder.RegisterModule(new ApplicationModule());
…

Dr. Strangelove
- 2,725
- 3
- 34
- 61
2
votes
0 answers
Share an instance between modules
I have two autofac modules WorldModule and RegionModule (separte class that inherits Module) and overwrite the load function. Both must share a worldService, service that uses an world model (singleton).
This is the worldmodule class:
…

Dan Cehan
- 41
- 5
2
votes
1 answer
Placement of the Autofac Module class in a solution
I have been reading a lot of sample code for DI and autofac. One thing I noticed was that many people bundle the interfaces and implementations in the same project. From design point, I believe this is not correct and all interfaces should be in…

Hemant
- 411
- 4
- 15
2
votes
0 answers
Autofac RegisterAssemblyModules throws Autofac.Core.DependencyResolutionException
I have a WebAPI 2 that uses Autofac. Below works, but RegisterAssemblyModules throws DependencyResolutionException
builder.RegisterModule(); //works
builder.RegisterModule();
…

Pingpong
- 7,681
- 21
- 83
- 209