I have a .net framework class library project which is absolutely working fine with the .net framework projects, Now I need to refer it in .net core application also. so I am trying to create a new .net standard project and copied all the .cs files to this project from the existing project. and started fixing the compilation errors. I have fixed many but still getting a few.

string applicationName = System.Configuration.ConfigurationManager.AppSettings["Application"];

On the above line, it's giving the below error.

type or namespace name 'ConfigurationManager' does not exist in the namespace 'System.Configuration'

Tried so far:

  1. I have added the package System.Configuration.ConfigurationManager from Nuget
  2. Tried adding System.Configuration.dll from Reference Manager but it shows nothing for System.Configuration.dll

How to solve this issue in the .net standard class library? Or is it not supported at all?

In another way, question can be how to read appsettings.json file in .net standard class library?

2

There are 2 best solutions below

1
On BEST ANSWER

I solved the issue by adding Microsoft.Extensions.Configuration to the project from the NuGet package manager.

3
On

I faced the same problem for Visual Studio 2019.

This helped me resolve it:

Right click on project and go to Manage NuGet Packages.

enter image description here

Search for System.Configuraion and install System.Configuration.ConfigurationManager

enter image description here

Now in your code, configuration manager will be recognized.

enter image description here