2017-10-11 72 views
0

「file」属性を使用して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> 

誰もが私を助けることができるの下にありますこの?

ありがとうございます。

答えて

0

私にとってこれは経路の問題でした。 Visual Studioのデフォルトの動作は、出力ディレクトリにファイルを含めないことです。私はあなたが最新のファイルを持っていることを確認するために、各ビルドのファイルプロパティを「常にコピーする」に変更しました。プロパティセクションでプロジェクトに追加した場合は、ファイル参照にパス内のプロパティフォルダを含める必要があります。

関連する問題