title: The configuration file has been changed by another program in C#
body: <p>I am working in C# Windows Form Application. I am using 2 forms for my application. And I have one <em>app.config</em> file to save the settings run time. </p>
  
  <p>I have a button in my Form1 to open the Form2. I have some settings to be saved in the Form2 as well as Form1. </p>
  
  <p>I made my app running. While running I updated a setting in app.config through Form1. After that I clicked on the button to open the Form2 and made some modifications and tried to save the settings to the same app.config file. But it threw an exception saying </p>
  
  <blockquote>
    <p>The configuration file has been changed by another program.</p>
  </blockquote>
  
  <p>I couldn't figure it out where I went wrong. Please help me to make it work.
  Thanks in advance.</p>
  
  <p>EDIT 1:
  This is the function I have in the form 1</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e)
      {
  
          config1.AppSettings.Settings.Add("no_of_cameras", null);
          config1.AppSettings.Settings["no_of_cameras"].Value = (no.Value).ToString("G");
          config1.Save(ConfigurationSaveMode.Modified);
          ConfigurationManager.RefreshSection("appSettings");
  
          Properties.Settings.Default.Reload();
      }
  </code></pre>
  
  <p>And this is the function in my Form 2:</p>
  
  <pre><code>    private void radioButton1_CheckedChanged(object sender, EventArgs e)
      {
          config2.AppSettings.Settings.Add("mail_enable", null);
  
          if (radioButton1.Checked == true)
          {
              label1.Show();
              textBox1.Show();
              config2.AppSettings.Settings["mail_enable"].Value = "true";
              config2.Save(ConfigurationSaveMode.Modified);
              ConfigurationManager.RefreshSection("appSettings");
          }
          else
          {
              config2.AppSettings.Settings["mail_enable"].Value = "false";
              config2.Save(ConfigurationSaveMode.Modified);
              ConfigurationManager.RefreshSection("appSettings");
              textBox1.Hide();
              label1.Hide();
          }
  
          Properties.Settings.Default.Reload();
      }
  </code></pre>