title: .Net configuration - How to override settings and custom sections in a mapped configuration file?
body: <p>If I have in myprogram.exe.config file:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="fooSection" type="MyNamespace.MySection, My.Assembly"/&gt;
    &lt;/configSections&gt;
    &lt;appSettings&gt;
      &lt;add key="foo" value="bar"/&gt;
    &lt;/appSettings&gt;
    &lt;fooSection&gt;
      &lt;bar&gt;
        &lt;add baz="foo bar baz"/&gt;
      &lt;/bar&gt;
    &lt;/fooSection&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>and I have in overrides.config file:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="fooSection" type="MyNamespace.MySection, My.Assembly"/&gt;
    &lt;/configSections&gt;
    &lt;appSettings&gt;
      &lt;add key="foo" value="BAZ"/&gt;
    &lt;/appSettings&gt;
    &lt;fooSection&gt;
      &lt;bar&gt;
        &lt;add baz2="foo foo"/&gt;
      &lt;/bar&gt;
    &lt;/fooSection&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Is there any way to have this read into the core (or loaded) configuration, like you would get with the machine->app config file precendence?  (or even machine.config -> machine root web.config -> local app web.config)</p>
  
  <p>In this example, I would like config.AppSettings["foo"] to be "BAZ" and fooSection to contain two items: "foo bar baz" and "foo foo".</p>
  
  <p>I cannot find a way, and am guessing it may not be supported.  I've tried many permutations.</p>
  
  <pre><code>MySection section = ConfigurationManager.GetSection("foo") as MySection;
  
  ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
  fileMap.LocalUserConfigFilename = // have tried this;
  fileMap.ExeConfigFilename = // have tried this
  Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
  ConfigurationManager.RefreshSection("foo");
  
  foo = ConfigurationManager.GetSection("foo") as MySection;
  // will only have one item
  foo = config.GetSection("foo") as MySection;
  // will only have one item
  </code></pre>