構成ファイルに値を追加した後、すぐにアプリケーションに読み込めない理由を誰かが理解するのを手伝ってくれますか? リフレッシュしますが、うまくいきません。下記参照:
public void AddConfig(string key_value, string actual_value)
{
// Open App.Config of executable
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
//If it exists, remove it first
config.AppSettings.Settings.Remove(key_value);
// Add an Application Setting.
config.AppSettings.Settings.Add(key_value, actual_value);
// Save the configuration file.
config.Save(ConfigurationSaveMode.Modified);
// Force a reload of a changed section.
ConfigurationManager.RefreshSection("appSettings");
string blah = ConfigurationManager.AppSettings[key_value];
MessageBox.Show(blah);
}
メッセージ ボックスは null/空白として表示されます。
アプリケーションを再起動し、別のコマンドを実行して起動後にキー値を読み取ると、機能します。
何か案は?