Questions tagged [autofac-module]
82 questions
2
votes
1 answer
Autofac in a Multi-Project Solution
I'm using Autofac as a dependency injection system in a C# solution that spans several class libraries and several executables. I'm using modules to configure Autofac, but that still leaves me with the issue of building the DI container, which…

Mark Olbert
- 6,584
- 9
- 35
- 69
2
votes
2 answers
Autofac - Delegate Factories + Type Interceptors together
I am trying to get AutoFac Delegate Factories & Type Interceptors to play nicely with each other, but I cannot seem to get the behaviour I want.…

Codebrain
- 5,565
- 4
- 28
- 21
2
votes
1 answer
Autofac job activator with Hangfire throwing exception DependencyResolutionException
My project structure is same as :
https://github.com/MarlabsInc/webapi-angularjs-spa
I have followed the instructions in :
http://docs.hangfire.io/en/latest/background-methods/using-ioc-containers.html
So I have created a container job…

user3825003
- 191
- 1
- 5
- 12
1
vote
1 answer
ILogger not resolved in Azure Functions startup class using Autofac
I'm trying to get instance of ILogger when resolving a dependency in the Startup class of an Azure Function v4 in process version.
Only this doesn't work and will result in an exception, null or a not working logger.
I followed the following…

LockTar
- 5,364
- 3
- 46
- 72
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
How to pass parameter to an Autofac Module from a resolve dependency
Currently I have a autofac module which receives a string as parameter, and that string is coming from another dependency.
Im trying to pass it using below code, my question is: Is this the right approach or there is a better/improved way to do…

F3D3
- 13
- 2
1
vote
1 answer
How do you provide specific registrations in Autofac as parameters to other registrations?
Can you plase provide some guidance on how to pass some references to other registrations ?
//registration of 1st http client
builder.RegisterType()
//.Keyed("authHttpClient")
.WithProperties(new[] {…

mesteves
- 408
- 4
- 8
1
vote
0 answers
Use existing IContainer in new instance of Autofac container
I have solution with .NET Core 3.1 console application, which using Autofac as IoC container. In this solution is approximately 50 projects as class libraries, which is referenced over Autofac as modules. Now I am creating new module, which will…

Jara
- 11
- 2
1
vote
2 answers
How to access service of another project in same solution
I have a console app A and a web app B where A needs to use a service class in B. To deal with dependencies I tried to make an autofac module in B that is registered in A's Main method:
public class ImageServiceModule : Module
{
protected…

Agnete
- 53
- 1
- 8
1
vote
2 answers
Autofac: Needed: End-Of-Lifetime event for instances handled in a AutofacModule
I use C# and Autofac 4.9.4.
I have an Autofac Module which hooks up to the IComponentRegistration.Activated event. It looks for activated instances of certain classes and registers them in some manager class.
This registration should be limited to…

JSpot
- 450
- 4
- 12
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
Dependencies of a module
I'm learning AutoFac.
I like the idea of modules. From my understanding, I could for example create a module that registers some part of my application dependencies to the container to create some abstraction above it. However, I don't really know…

Loreno
- 668
- 8
- 26
1
vote
1 answer
How can I get constructor parameters of autofac component on activating
What I want is create caching proxies for all my components decorated with some attributes. So, I made Autofac Module like this:
public class CachingModule : Autofac.Module
{
private readonly ProxyGenerator generator;
public…

xumix
- 593
- 7
- 17
1
vote
1 answer
Inject JSON file with Autofac
I need load a JSON file with Autofac (IoC), and I'm following the official tutorial: http://autofaccn.readthedocs.io/en/latest/configuration/xml.html#quick-start
All the code is correct, but the ConfigurationModule class is not recognized:
var…

Jhon Duck
- 357
- 4
- 14
1
vote
0 answers
autofac registration in webapi some singleton components some per request
Our framework has the following structure:
webapi project
basic CQRS project
Nhibnerate configuration project
The solution uses Autofac to wire up all the classes. The api will load all assemblies and register all the modules in those…

Jon
- 15,110
- 28
- 92
- 132