0
我试图使用“文件”属性将appSettings config部分移至外部文件,并继续获取错误:错误“根元素必须与引用文件的部分的名称相匹配”,当根元素与部分的名称匹配时
System.Configuration.ConfigurationErrorsException : The root element must match the name of the section referencing the file, '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>
谁能帮我这个?
谢谢。