Предоставление другого файла конфигурации конструктору ConfigurationSettingsReader - PullRequest
0 голосов
/ 12 марта 2012

, когда я пытаюсь установить конфигурацию своего регистра в каком-то другом файле, кроме app.config, я пробую это решение:

var builder = new ContainerBuilder();
builder.RegisterModule(new ConfigurationSettingsReader("autofac", "Other.config");

К сожалению, это не работает, я получаю информацию, что раздел "autofac" можетне читайте.

Вот мой Other.config:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration"/>
  </configSections>

  <autofac>
    <components>
      <component type="IoCConsoleApplication1.Car, IoCConsoleApplication1">
        <properties>
          <property name="Description" value="CIĘŻAROWY"/>
        </properties>
      </component>
    </components>
  </autofac>
  <startup>
    <supportedRuntime version="v2.0.50727" sku="Client"/>
  </startup>
</configuration>

Есть идеи, что здесь не так?

С уважением, Лукаш

1 Ответ

1 голос
/ 12 марта 2012

Перейдите к привязке к пользовательскому файлу app.config:

AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE","c:\\custom.config");
...