I'm trying to add reference to System.Configuration.dll
assembly.
I'm using .Net Core, as it can be seen in my .csproj
file:
<TargetFramework>netcoreapp2.2</TargetFramework>
(Output type of my project is set to Class Library
.)
To do this, in solution explorer, I right-click on Dependencies
of my project and then click on Add Reference...
. Problem is that the opened Reference Manager is empty and there is no assembly I can add a reference to.
However, without referencing that assembly I'm able to write the following line without any build error:
using System.Configuration;
First Question: How is it possible that the above line gets successfully built, without me referencing that assembly?
If I try to use ConfigurationManager
class to read data from app.config file (As told here ), I get an error complaining that:
CS0103 The name 'ConfigurationManager' does not exist in the current context
Question two: what can I do to solve that error? what's wrong with my code or project?
My case is not the same as this question and this is not a duplicate of that question.
Add Reference
is for your local references. You need to use Nuget Package Manager in order to include references.
most importantly .Net Core does not use .Net Framework packages where ConfigurationManager
is .Net Framework package.
You need to use .Net Core or .Net Standard libraries with .Net Core