zcz527 / autofac

Automatically exported from code.google.com/p/autofac
Other
0 stars 0 forks source link

Autofac configuration section in separate file with web.config #247

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am using Autofac for multiple projects and all projects work fine with 
Autofac mapped to an external file using the following configuration arguments.

App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration" />
  </configSections>
  <autofac defaultAssembly="MyAssembly">
    <files>
      <file name="autofac.config" section="autofac" />
    </files>
  </autofac>
</configuration>

Autofac.Config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration" />
  </configSections>  
  <autofac defaultAssembly="MyAssembly">
    <components>
      <component service="IComponent, MyAssembly" type="Component, MyAssembly"/>
    </components>
  </autofac>
</configuration>

When I am using the same configuration from app.config in web.config I receive 
the following exception.

[ArgumentException: The configuration section 'autofac' could not be read.]
   Autofac.Configuration.ConfigurationSettingsReader..ctor(String sectionName, String configurationFile) +244
   Autofac.Configuration.ConfigurationSettingsReader.Load(ContainerBuilder builder) +2862
   Autofac.Module.Configure(IComponentRegistry componentRegistry) +59
   Autofac.ContainerBuilder.Build(IComponentRegistry componentRegistry) +281
   Autofac.ContainerBuilder.Build() +35

I am using Autofac 2.1.13.813. If I do not use an external file and inline the 
autofac.config into our web.config file all works as expected. Only when we use 
the external file I receive the error.

Original issue reported on code.google.com by Mike737...@gmail.com on 4 Aug 2010 at 2:51

GoogleCodeExporter commented 8 years ago
Thanks for the report Mike. I believe this was just fixed in r985 but won't be 
available until 2.3 is officially released.

Original comment by nicholas...@gmail.com on 5 Aug 2010 at 12:06