I have an application using Autofac at the moment. I designed autorun to register from the configuration file after loading the modules. (To override xml-based default behavior).
Now I have a class with a lot of basic environment settings (in fact, a lot of public auto-properties). This class tries to guess the default configuration based on some settings, but the idea is that every environment in which the application runs will override these parameters in the xml configuration.
Here is my problem:
Previously, in the development of this system, everything was Persian. Now it seems to completely ignore XML Configs input. I'm not sure what has changed, what caused it to break, so I hope that someone can point out something obvious, I'm doing wrong.
I checked that the configuration file is read / parsed using autofac, just not applicable.
web.config:
<autofac> <files> <file name="Config/Environment.config" section="autofac-common" /> <file name="Config/Environment.config" section="autofac-public" /> </files> </autofac>
Environment.config:
<configuration> <configSections> <section name="autofac-common" type="Autofac.Configuration.SectionHandler, Autofac.Configuration"/> <section name="autofac-public" type="Autofac.Configuration.SectionHandler, Autofac.Configuration"/> </configSections> <autofac-common> <components> <component type="MyApp.Web.Configuration.ServerConfiguration, MyApp.Web" service="MyApp.Web.Configuration.IServerConfiguration, MyApp.Web"> <properties> <property name="Host" value="beta.mysite.com" /> <property name="MediaHost" value="beta.media.mysite.com" /> </properties> </component> </components> </autofac-common> <autofac-public> <modules> <module type="MyApp.Configuration.CachingModule, MyApp"> <properties> <property name="Disable" value="true" /> </properties> </module> </modules> </autofac-public> </configuration>
Container design code
var builder = new ContainerBuilder(); // Register Identifier so it available to modules builder.RegisterType<ServerIdentifier>() .As<IServerIdentifier>() .SingleInstance(); var container = builder.Build(); builder = new ContainerBuilder(); builder.RegisterModule(new CachingModule() { Disable = true }); builder.RegisterModule(new LoggerModule()); builder.RegisterModule(new InventoryModule()); builder.RegisterModule(new CatalogModule()); builder.RegisterModule(new WebModule(container)); // Override with settings from XML builder.RegisterModule(new ConfigurationSettingsReader("autofac")); builder.Update(container);
Autofac Version 2.3.2.632 For .NET 3.5
source share