autofac-configuration

Read modules from web.config in autofac to change container configuration according to solution configurations

断了今生、忘了曾经 提交于 2020-01-06 06:51:35
问题 I have created some Autofac modules... Now I want to register some of them in my container using web.config... In my web.config I have written: <autofac defaultAssembly="Autofac.Example"> <modules> <module type="DebugModuleTest1"></module> <module type="DebugModuleTest2"></module> </modules> </autofac> Now I have to build my container. But the autofac documentation is not clear to me. I do not understand what I have to do to read my modules and build the container. public class

Autofac scope configuration for multi-project solution

血红的双手。 提交于 2019-12-13 03:46:10
问题 I have an ASP.NET web application which until now has been using an Autofac configuration class which has specified an InstancePerRequest() for services in the application. Since then, I have created a new console application in the same solution which will be responsible for running automated job processes. Since I can't use the InstancePerRequest configuration for my console application, then I need to make a change to my configuration. Ideally, I don't want to copy and paste all the

ConfigurationModule passed into Module and context - DotNet Core

两盒软妹~` 提交于 2019-12-11 16:31:54
问题 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 ConfigurationBuilder. var config = new ConfigurationBuilder(); config.AddJsonFile("appsettings.json"); var containerBuilder = new ContainerBuilder(); // Register the ConfigurationModule with Autofac. var configurationModule = new ConfigurationModule(config.Build());

Autofac - How to resolve instances registered using JSON Configuration

纵饮孤独 提交于 2019-12-11 16:02:46
问题 Our requirement is to have different Logger instances for different user defined threads. { "defaultAssembly": "Framework", "components": [ { "type": "SynapseMiddleware.Core.Framework.LoggerServicePerContext, Framework", "services": [ { "type": "SynapseMiddleware.Core.Framework.ILoggerServicePerContext, Framework" } ], "parameters": { "loggerConfig": "18105" } }, { "type": "SynapseMiddleware.Core.Framework.LoggerServicePerContext, Framework", "services": [ { "type": "SynapseMiddleware.Core

Autofac - Make sure that the controller has a parameterless public constructor

青春壹個敷衍的年華 提交于 2019-12-04 16:51:32
问题 I know it's been asked and answered before - the reason I'm asking is because (I think) I tried all suggested solutions to this problem but still can't resolve it. I have an ASP.NET Web API 2.0 project. I have Autofac , Autofac.Mvc5 and Autofac.WebApi2 dependencies installed. When I try to call an API controller I get the following error: An error occurred when trying to create a controller of type 'MyController'. Make sure that the controller has a parameterless public constructor. In my

Autofac - Make sure that the controller has a parameterless public constructor

喜欢而已 提交于 2019-12-03 10:39:18
I know it's been asked and answered before - the reason I'm asking is because (I think) I tried all suggested solutions to this problem but still can't resolve it. I have an ASP.NET Web API 2.0 project. I have Autofac , Autofac.Mvc5 and Autofac.WebApi2 dependencies installed. When I try to call an API controller I get the following error: An error occurred when trying to create a controller of type 'MyController'. Make sure that the controller has a parameterless public constructor. In my Global.asax I have a call to IocConfig.Config() which I have placed inside App_Start : public static class