Questions tagged [autofac-configuration]
88 questions
1
vote
0 answers
AutoFac equivalent of this ninject command/function
In Ninject i can configure a container like the mentioned below, What is the Autofac equivalent for the "Highlighted ones"?
Currently i am trying to achieve the same using AutoFac, any help is much appreciated.
public class NinjectAdapter :…

Cody
- 41
- 3
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
2 answers
.NET Core Console App services.AddAutofac() Not Working
I am attempting to use Autofac with a .NET Core console application using the Microsoft.Extensions.DependencyInjection and Autofac.Extensions.DependencyInjection packages but the load methods inside my modules never get invoked and leads to Program…

Adam
- 4,590
- 10
- 51
- 84
1
vote
1 answer
Register type as InstancePerRequest with Exception(s)
I am using AutoFac in my Web API application (using the latest versions available as of time this question was posted). One of my service dependencies is an AuditService which uses an instance of by DbContext type (let's call it MyDbContext for…

Igor
- 60,821
- 10
- 100
- 175
1
vote
1 answer
ConfigurationModule passed into Module and context - DotNet Core
So I'm trying to use Autofac DI to pass my configuration json file through the stack. My Main function is as follows:
static void Main(string[] args)
{
Console.WriteLine("Starting...");
// Add the configuration to the…

Chris
- 805
- 6
- 19
1
vote
1 answer
Autofac OWIN web api - load dependency based on request
How I can load a service dependency based on the route parameter?
My requirement is different, but I'll try to use a simple example.
A user can select the shipping provider (UPS, Fedex...) and the information is as part of the request model or…

Johny
- 11
- 2
1
vote
0 answers
WebAPI2, OWIN and AutoFac: Cannot Inject anything into any controller
I've scoured the internet and stack overflow but simply cannot work out why my AutoFac flatly refuses to inject anything into any controller. My code is below - everything SEEMS to be in order but I receive the following message:
An error occurred…

Luke Baughan
- 4,658
- 3
- 31
- 54
1
vote
1 answer
AutoFac - How to register and resolve an object with parameter?
public class FooController : ApiController
{
private IDb db;
public FooController (IDb context)
{
db = context;
}
public void DoSomething(string value)
{
var output = new DoSomethingElse(value);
…

sundar
- 235
- 2
- 11
0
votes
1 answer
Export an autofac container to its identical json configuration file
Is there a way to take an existing Autofac Module, Container or ContainerBuilder and use it to generate an equivalent json file that can be loaded via configuration extensions?
For some background, we have a large code base with hundreds of…

chanban
- 480
- 1
- 4
- 19
0
votes
0 answers
AutoFac get multiple instances of same service injected but constructed differently
Is it possible to resolve multiple instances of the same service registered for an interface but constructed with different parameters?
For example, I have a Interface and Service:
public interface INotificationService
{
Task PublishAsync(string…

smk081
- 783
- 1
- 10
- 36
0
votes
1 answer
Autofac RegisterAssemblyOpenGenericTypes matching query
I'm attempting to register all open generic components I tag with a custom attribute. The query finds the class correctly but the interface is not registered properly. I'm able to register and resolve the component fine using…

Eric Williams
- 35
- 7
0
votes
0 answers
Unable to inject object by method with Autofac in multiple assembly project in .NET Framework 4.8
I have a problem with method injection between assemblies in a multiple assembly project. It only works for me in the scope of the Assembly1 with Autofac configuration.
I set the Autofac with the below packages: Autofac 3.5.2, Autofac.MVC4 3.1.0,…

Lampart123
- 3
- 3
0
votes
1 answer
Implementing IConfiguration with Autofac
im trying to use Autofac and configure an appconfig.json:
private static void RegisterAppSettingsConfiguration(ContainerBuilder builder)
{
var config = new ConfigurationBuilder()
…

Erythana
- 41
- 4
0
votes
2 answers
I have installed autoFac and AutoFac.Mvc5 both but RegisterControllers() method is not Available
here is screenshot of IDE
I have installed autofac and autofac.mvc5 both packages but RegisterControllers() method is not available and also "Using AutoFac.Integeration.Mvc" Namespace not accessible and showing error.
here is my code
using…

waqas
- 1
- 4
0
votes
1 answer
inject module properties to dynamically registered component
When using autofac json configuration to register modules you can pass in properties and/or parameters.
{
"modules": [
{
"type": "MyProject.Core.MyModule, MyProject.Core",
"properties": {
"ModuleProperties": {
…

Christopher Taus
- 1
- 1