我有一个类似的项目结构:
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.
有什么想法吗?配置在哪里寻找?