应用程序配置无法选择组装

时间:2016-09-23 12:49:38

标签: c# app-config

我有一个类似的项目结构:

App
|__UI.exe
|__folder
   |__Assembly.dll
   |__Assembly.dll.config

Assembly.dll.config的内容是:

<configuration>
  <appSettings>
    <add key="backend" value="qa"/>
  </appSetings>
  <configSections>
    <section name="qa" type="Backend.Implementations.Lest.Settings.BackendSection,Assembly"/>
    <section name="dev" type="Backend.Implementations.Lest.Settings.BackendSection,Assembly"/>
  </configSections>
  <qa scope="qa">
    <endpoints>
      <endpoint host="localhost" port="1111" app="webapi"/>
      <endpoint host="localhost" port="2222" app="authz"/>
    </endpoints>
  </qa>
  <dev scope="development">
    <endpoints>
      <endpoint host="localhost" port="1111" app="webapi"/>
      <endpoint host="localhost" port="2222" app="authz"/>
    </endpoints>
  </dev>
</configuration>

当我试图从Assembly查找位于其所在的同一文件夹的配置时,我收到ConfigurationErrorsException in System.Configuration.dll告诉我:

  

加载Assembly程序集是不可能的。系统无法找到   指定的文件。

这是我用来加载配置的代码:

Configuration configuration = ConfigurationManager.OpenExeConfiguration((System.Reflection.Assembly.GetAssembly(typeof(LESTBackend))).Location);
ConfigurationSection section = configuration.GetSection("qa"); << Here the exception is raised.

有什么想法吗?配置在哪里寻找?

0 个答案:

没有答案