title: How to read an App.Config of a different application in C#
body: <p>I have a console application written in C# which uses an app.config file. This application is intended to be run on a server using the task scheduler. Now I want to develop a UI that reads and writes from and to the app.config. (Note that this config is not intended to replace the config file of the UI application.)</p>
  
  <p>But I'm struggling to read the settings from the file. Using the ConfigurationManager I'm able to open the config file, BUT I cannot access the configuration settings.</p>
  
  <p>This is the sample config file generated by Visual Studio (2010):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;configSections&gt;
          &lt;sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" &gt;
              &lt;section name="AccessingConfigSample.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /&gt;
          &lt;/sectionGroup&gt;
      &lt;/configSections&gt;
      &lt;userSettings&gt;
          &lt;AccessingConfigSample.Properties.Settings&gt;
              &lt;setting name="ApplicationTitle" serializeAs="String"&gt;
                  &lt;value&gt;Accessing Config files&lt;/value&gt;
              &lt;/setting&gt;
              &lt;setting name="VersionNo" serializeAs="String"&gt;
                  &lt;value&gt;V 1.0&lt;/value&gt;
              &lt;/setting&gt;
          &lt;/AccessingConfigSample.Properties.Settings&gt;
      &lt;/userSettings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>After consulting several article on stackoverflow, I tried this to open the file and access the user section:</p>
  
  <pre><code>if (File.Exists(configFile))
  {
     var configMap = new ExeConfigurationFileMap{ ExeConfigFilename = configFile};
     var config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
     var userSection = config.GetSection("userSettings");
  }
  </code></pre>
  
  <p>I tried this as well:</p>
  
  <pre><code>var userSection = config.GetSection("AccessingConfigSample.Properties.Settings");
  </code></pre>
  
  <p>Both returned <strong>null</strong>.</p>
  
  <p>So what am I doing wrong here?</p>
  
  <p>Any help or hints are highly appreciated!</p>