tagged [autofac]
Automatically bind interfaces using AutoFac
Automatically bind interfaces using AutoFac I have some classes like UserQuery, CustomerQuery implementing interfaces like IUserQuery, ICustomerQuery respectively. In my binding configuration I need t...
- Modified
- 30 Jan at 12:22
How do you do dependency injection with AutoFac and OWIN?
How do you do dependency injection with AutoFac and OWIN? This is for MVC5 and the new pipeline. I cannot find a good example anywhere. ``` public static void ConfigureIoc(IAppBuilder app) { var bui...
- Modified
- 22 Apr at 01:47
Using Autofac to inject a dependency into the Main entry point in a console app
Using Autofac to inject a dependency into the Main entry point in a console app Say I have a simple console application: What is the simplest way I can use Autofac to inject the Log instance and ensur...
Resolving Hangfire dependencies/HttpContext in .NET Core Startup
Resolving Hangfire dependencies/HttpContext in .NET Core Startup I've installed and configured Hangfire in my .NET Core web application's Startup class as follows (with a lot of the non-Hangfire code ...
- Modified
- 30 May at 17:37
How to get Microsoft.Extensions.Logging<T> in console application using Serilog and AutoFac?
How to get Microsoft.Extensions.Logging in console application using Serilog and AutoFac? We have common BL classes in a ASP.NET Core application that get in the ctor: `Microsoft.Extensions.Logging.IL...
- Modified
- 1 Jan at 15:11
Autofac Scanning Assemblies for certain class type
Autofac Scanning Assemblies for certain class type I've started using `Autofac` and want to scan some DLL's and get `Autofac` to register some of the classes within them. The classes that I'm interest...
- Modified
- 19 May at 04:11
How to resolve interface based on service where it's passed to
How to resolve interface based on service where it's passed to I have an interface. and two implementations (SomeImpl1 and SomeImpl2): I also have two services where I inject ISomeInterface (via contr...
Resolving Generic Interface with Autofac
Resolving Generic Interface with Autofac Given the following code, how do I resolve the right SomeInstance in autofac? ``` public class BaseClass {} public class SubClass1 : BaseClass {} public class ...
Register Dependencies in another Project
Register Dependencies in another Project My Models and DataContext are in another project to my Web MVC project in my solution. When I try to register my DataContext inside `AppHost` `Configure` metho...
- Modified
- 26 Mar at 15:34
Return same instance for multiple interfaces
Return same instance for multiple interfaces I'm registering components with the following code: ``` StandardKernel kernel = new StandardKernel(); string currentDirectory = Path.GetDirectoryName(GetTy...
autofac's Func<T> to resolve named service
autofac's Func to resolve named service Given registered services: Can I retrieve named implementations of `IFoo` interface by injecting something like `Func` ? ``` public class SomeClass
- Modified
- 19 Sep at 14:23
Register partically closed generic type with Autofac
Register partically closed generic type with Autofac I have `UnitofWork` class and it implement `IUnitOfWork`. I try to register that with Autofac: Implementation is: ``` public class UnitOfWork : IUn...
- Modified
- 28 Feb at 13:36
Does autofac supports the new Web Api 2
Does autofac supports the new Web Api 2 I'm developing a web api as part of a MVC/API ASP.NET on VS 2013, MVC 5, API 2, but my `AutofacWebApiDependencyResolver` throws an exception every time I try to...
- Modified
- 26 Dec at 20:55
Is it possible to remove an existing registration from Autofac container builder?
Is it possible to remove an existing registration from Autofac container builder? Something along those lines: ``` builder.RegisterType().As(); builder.RegisterType().As(); builder.DeRegisterType().As...
Autofac test all registered types can be resolved
Autofac test all registered types can be resolved I have a bunch of types registered with Autofac and some of the dependencies are rather deep. Is there a built in way to test that I can resolve all r...
Autofac: Batch registration of open-generic types
Autofac: Batch registration of open-generic types I got an assembly with many concrete types that implement `IHandler`, such as the following: Currently, I'm registering the
- Modified
- 5 Feb at 22:12
Unable to cast object of type ServiceCollection to type 'Autofac.ContainerBuilder' using dotnet core and autofac
Unable to cast object of type ServiceCollection to type 'Autofac.ContainerBuilder' using dotnet core and autofac I am trying to use `autofac` in my `dotnet core 3.1` project, but I am unable to run pr...
How to call async method in Autofac registration?
How to call async method in Autofac registration? I want to do call an `awaitable async` method during a registration like this: ``` // builder variable contains Autofac ContainerBuilder builder.Regis...
- Modified
- 7 Jul at 10:22
Register a decorator in autofac without manually specifying all dependencies
Register a decorator in autofac without manually specifying all dependencies I have a decorator that has some other dependencies that should also be resolved using the container. Example: I can regist...
- Modified
- 20 Jun at 13:38
'ConfigureServices returning a System.IServiceProvider isn't supported.'
'ConfigureServices returning a System.IServiceProvider isn't supported.' I need ti use this `AutoFac` in ASP core 3.0 When I use this code in startu up: It show me this error: > 'ConfigureServices ret...
- Modified
- 27 Sep at 11:31
Using autofac with moq
Using autofac with moq I need to register my Autofac container with specific interface, for this case I want to resolved mock. How can I do it? I've tried: I don't want to change my c
Registering implementations of base class with Autofac to pass in via IEnumerable
Registering implementations of base class with Autofac to pass in via IEnumerable I have a base class, and a series of other classes inheriting from this: > public abstract class Animal { }public clas...
- Modified
- 4 Dec at 10:36
Hangfire dependency injection lifetime scope
Hangfire dependency injection lifetime scope I'm rewriting this entire question because I realize the cause, but still need a solution: I have a recurring job in Hangfire that runs every minute and ch...
Servicestack with Autofac not resolving IRequestContext
Servicestack with Autofac not resolving IRequestContext I am trying to use the Cache facilities of Service Stack. These are accessed through the RequestContext, which is injected by the IOC in your Se...
- Modified
- 24 Jan at 08:31
Property Injection for Base Controller Class
Property Injection for Base Controller Class I'm trying to automatically set a property on any controller that derives from my `BaseController` class. Here is the code in my `Application_Start` method...
- Modified
- 29 Dec at 08:29