【发布时间】:2017-10-11 10:17:54
【问题描述】:
我正在尝试使用“文件”属性将 appSettings 配置部分移动到外部文件并不断收到错误:
System.Configuration.ConfigurationErrorsException : 根元素 必须与引用文件的部分的名称“appSettings”相匹配
问题是外部文件中的根元素已经是“appSettings”。 尝试使用根“配置”和自定义配置部分,但也没有帮助
外部文件Test.config在下面
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="URL" value="https://www.google.com" />
</appSettings>
主App.config文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
</configSections>
<specFlow>
<!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
</specFlow>
<appSettings file="Test.config"/>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
谁能帮我解决这个问题?
谢谢。
【问题讨论】: