Questions tagged [autofac-configuration]

88 questions
0
votes
0 answers

Accesing Application DI Container in Configure Services

With .net core 3 and above ConfigureServices method doesn't return IServiceprovider. We used to configure Autofac in the ConfigureServices method and use it to resolve the registered proxies for our Controllers so that we could add the controllers…
Sameed
  • 655
  • 1
  • 5
  • 18
0
votes
1 answer

Inject two objects of same type using autofac

I have been trying to register and inject two different objects of the same type using autofac, but I am unable to get the second object injected successfully. The second object injected is always either the same instance of type 1 registered first…
tjmn
  • 469
  • 1
  • 6
  • 11
0
votes
1 answer

How do I configure the DbContext in an Autofac json configuration file

ENV: VS 2019, C# .NET Framework 4.6.1 I'm using a .json file to hold all my configurations: IConfigurationBuilder config = new ConfigurationBuilder(); config.AddJsonFile("autofac.json"); My question is, how do I include the DbContext in…
0
votes
1 answer

Is there a way of registering all interfaces in Autofac for a component using JSON configuration similar to .AsImplementedInterfaces()

Is it possible to have some components registered through JSON in the same way one would register a component with .AsImplementedInterfaces()? Or are modules the only way to do this? Thank you.
Craig
  • 15
  • 4
0
votes
1 answer

Resolve type with explicit instance

I use AutoFac. I have to resolve a type with an explicit instance which I get from another service. For example: I have an instance of type Client which I get from somewhere (not from the container). I want to configure the Autofac container so that…
BennoDual
  • 5,865
  • 15
  • 67
  • 153
0
votes
1 answer

Which lifecycle is best for using Entity Framework with Autofac in ASP.Net MVC?

I am new to Autofac and I am using it as a dependency container. I want to register my DB context. This is what I've done public static class AutofacConfig { public static void RegisterComponents() { var builder = new…
Mohammad Taherian
  • 1,622
  • 1
  • 15
  • 34
0
votes
1 answer

Replacing CastleWindsor with Autofac in .NETCore3.1

I was using CastleWindsor in my ASP.NETCore2.2 WebAPI project and was working fine. I'm migrating to ASP.NETCore3.1 now and it doesn't look like CastleWindor has offical support for that so I decided to move to Autofac with minimal changes but…
0
votes
1 answer

Dependency Injection into Autofac Module in .NET Core 3.0

I am quite new to creating and registering modules but I am trying to get a better understanding of the process as a whole. Currently I am trying to inject a dependency into an autofac module but I think the problem is that autofac registers its…
0
votes
2 answers

Assembly not found error during Autofac assembly scanning registration

I'm planning to auto-wire the interfaces and repositories in my project, both BL and DAL. but I'm encountering an issue which I have no idea on how to solve it. Here is the code namespace MovieManager.UI { public static class ContainerConfig …
Ranjith Varatharajan
  • 1,596
  • 1
  • 33
  • 76
0
votes
1 answer

AutofacWebApiDependencyResolver method doesnt exist

I am following this tutorial Youtube DI for dependency injection. This clear thing out for me however it does not show how to implement on a Web API using n-tier architecture. I also included followed this tutorial: C-Sharp AutoFac Web API…
Jseb
  • 1,926
  • 4
  • 29
  • 51
0
votes
2 answers

Mvc 4 to 5 upgrade issue - how to resolve Autofac security rules violation

I upgraded my asp.net web app (targetFramework 4.5.2) from mvc 4 to 5 according to this link. The solution compiles without errors however at runtime I get: The inheritance security rules were violated when the member…
Manu
  • 1,290
  • 5
  • 17
  • 32
0
votes
0 answers

method to peek at registered api urls in autofac register controllers

In attempt to debug api endpoint hit, the only information I am getting via postman is 404 with message file or directory does not exist on the server (IIS by the way). I wish there is a way to peek at registered endpoints via Autofac register…
swcraft
  • 2,014
  • 3
  • 22
  • 43
0
votes
1 answer

Autofac register all of type IFoo named IFoo.Name

Just learning Autofac and struggling to rgister a handful of named instances by convention. public interface IFoo { string AutoFactName{ get; } object DoSomething(); } looking at this interface what i am trying to accomplish is something…
workabyte
  • 3,496
  • 2
  • 27
  • 35
0
votes
1 answer

Autofac RegisterAssemblyTypes Injects Null in constructor parameter

The class public class CustomerRepository : ICustomer { public CustomerRepository(IEmailManager emailManager) { ... } } Autofac config var builder = new…
Greg Gorman
  • 196
  • 1
  • 9
0
votes
1 answer

What is the correct way to share dependency instances in Autofac?

I have three classes, say, A, B and C, so that: A depends on instances of B and C; B depends on an instance of C; Both A and B need to share the instance of C. How can I configure the container to have the things correctly wired with a single call…
vines
  • 5,160
  • 1
  • 27
  • 49