2012-07-27 3 views
8

多くの設定が含まれていますが、別のファイルの<appSettings />セクションも参照している私のapp.configに<appSettings />セクションがあるのは可能ですか?<appSettings />は設定を含み、別の<appSettings />セクションを参照することは可能ですか?

これは、開発者だけが興味を持っているはずの設定オプションを保持することを可能にします。メインウィンドウにデバッグ出力を表示するオプション(非常に混乱しますが、私には便利です)または特定のファイルを特定の場所に保存するオプション

具体的には、これは私が達成しようとしているものです:

<!-- this is the appSettings section of the normal app.config file, 
    which also contains everything else that app.config would --> 
<appSettings configSource="AppSettings.config"> <!-- references another file --> 
    <add key="deployment_config_option1" value="1"/> 
    <add key="deployment_config_option2" value="2"/> 
</appSettings> 

<!-- this a new appSettings section of another file called DevSettings.Config 
    which only contains settings us developers are interested in 
    by keeping these settings in a different file, 
    I can ensure it's never deployed --> 
<appSettings> <!-- references another file --> 
    <add key="show_debug_on_screen" value="true"/> 
    <add key="save_copy_to_desktop" value="false"/> 
</appSettings> 
+0

は、最も可能性の高いhttp://stackoverflow.com/questionsに重複しています/ 2560020/multiple-app-config-files –

+0

これは重複していません。その質問は私よりも一般的です。 – DaveDev

+0

基本的には同じことです。 app.configに他の設定を含めたいとします。 2番目の設定を展開したくない場合は、配備したapp.configのapp config includeを削除するだけです。 –

答えて

10

YES。docは可能なシナリオの数を考えればいくぶん薄いですが、以下の引用によると、appSettingsタグの場合のみマージがあります。

Web.configファイルへの変更は、別のファイルを使用して、アプリケーションを再起動する原因となりますので、ユーザーが再起動するアプリケーションを引き起こすことなくのappSettingsセクションにある値を変更することができます。 別のファイルの内容は、とWeb.configファイルのappSettingsセクションでマージされます。この機能はappSettings属性に制限されています。

ASP.NETの場合のこのテスト(下記)は、<add>タグを使用して動作することを示しています。従属ファイルに<clear>タグのような好奇心をそそるものを使用すると、明らかに問題が発生する可能性がありますが、私はそのような場合をテストしませんでした。 ASP以外の展開テクノロジは話せません。 Machine.Configもテストされていませんでした。 "_config \ AppSettings.config" ファイルで

<appSettings file="_config\AppSettings.Config"> 
      <add key="testing-1" value="Web.Config" /> 
    </appSettings> 

:web.configファイルで

<appSettings> 
      <add key="testing-2" value="_config/AppSettings.config" /> 
    </appSettings> 
+0

パーフェクト!あなたは私の日を救った、ありがとう – michal

関連する問題

 関連する問題