title: Change in application configuration without application restart
body: <p>I have following issue: I'm introducing new feature into application (run as Windows Service) and I would like to have that new feature controlled (on/off) using some kind of configuration file entry (<strong>myKey</strong>). I can store config entry in app.config but if I want to change it from on->off or otherwise it would require to restart Windows Service, and I want to avoid it. I want my application to run and pick up changes in configuration.</p>
  
  <p>The question is: is there a build in mechanism in .NET that addresses that problem ? I guess I could create my own config file, then use <code>FileSystemWatcher</code> etc... But perhaps .NET allows to use external config files and will reload value ??</p>
  
  <pre><code>ConfigurationManager.AppSettings["myKey"]
  </code></pre>
  
  <p>Thanks, Pawel</p>
  
  <p>EDIT 1: Thanks for replies. However I wrote following snippet and it doesn't work (I tried creating <strong>appSettingSection</strong> in both places: before and inside loop):</p>
  
  <pre><code>static void Main(string[] args)
  {
      Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
      // AppSettingsSection appSettingSection = (AppSettingsSection)config.GetSection("appSettings");
      for (int i = 0; i &lt; 10; i++)
      {
          ConfigurationManager.RefreshSection("appSettings");
          AppSettingsSection appSettingSection = (AppSettingsSection)config.GetSection("appSettings");
          string myConfigData = appSettingSection.Settings["myConfigData"].Value; // still the same value, doesn't get updated
          Console.WriteLine();
          Console.WriteLine("Using GetSection(string).");
          Console.WriteLine("AppSettings section:");
          Console.WriteLine(
            appSettingSection.SectionInformation.GetRawXml()); // also XML is still the same
          Console.ReadLine();
      }
  }
  </code></pre>
  
  <p>I manually edit config file when application stops on <strong>Console.ReadLine()</strong>.</p>