Quantcast
Channel: Reading settings from app.config or web.config in .NET - Stack Overflow
Viewing all articles
Browse latest Browse all 29

Answer by Dmitry Grinko for Reading settings from app.config or web.config in .NET

$
0
0

I'm using Visual Studio for Mac version 17.0.6.

As you can see on this screenshot it is not possible to add a reference to System.Configuration.

enter image description here

Solution:

  1. install NuGet Package - System.Configuration.ConfigurationManager.
  2. Create app.config file and set "Build action" to "EmbeddedResource"
<?xml version="1.0" encoding="utf-8"?><configuration><appSettings><add key="name" value="Joe"/></appSettings></configuration>
  1. using System.Configuration;
  2. enjoy)

string name = ConfigurationManager.AppSettings["name"];

BTW: Do not add an app.config for a library


Viewing all articles
Browse latest Browse all 29

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>