title: System.Configuration.ConfigurationManager vs Microsoft.Extensions.Configuration
body: <p>I am working on a class library(.NET Standard 2.0) CL, which will be used by some of our legacy projects(.NET Framework 4.6.1) LP and many of our new implementations(.NET Core 3.1) NI.</p>
  <p>My class library CL needs some of the configuration settings but when it is being used by new implementations NI, CL receives <code>Microsoft.Extensions.Configuration.IConfiguration</code>, as NI has <code>appSettings.json</code>.</p>
  <p>And when used from legacy projects LP, CL receives <code>System.Configuration.ConfigurationManager.AppSettings</code> as LP has either of <code>web.config</code> or <code>app.config</code>.</p>
  <p>Is there any elegant way to read configuration from both types of projects either .NET Framework or .NET Core? I don't want to read the configuration in projects like LP or NI who is consuming my library CL as that configuration is of no use to them.</p>
  <pre><code>private static void LoadConfiguration() // called from constructor
  {
    string receivedFromNETCore = configuration[&quot;DataMappingXml&quot;]; 
    // Microsoft.Extensions.Configuration.IConfiguration    
    string receivedFromNETFramework = 
    ConfigurationManager.AppSettings[&quot;DataMappingXml&quot;];
      
    // TODO: LOAD configuration and process.
  }
  </code></pre>