Home Reading settings from app.config or web.config in .net
Reply: 0

Reading settings from app.config or web.config in .net

user757
1#
user757 Published in June 25, 2018, 7:12 pm

I'm working on a C# class library that needs to be able to read settings from the web.config or app.config file (depending on whether the DLL is referenced from an ASP.NET web application or a Windows Forms application).

I've found that

ConfigurationSettings.AppSettings.Get("MySetting")

works, but that code has been marked as deprecated by Microsoft.

I've read that I should be using:

ConfigurationManager.AppSettings["MySetting"]

However, the System.Configuration.ConfigurationManager class doesn't seem to be available from a C# Class Library project.

Does anyone know what the best way to do this is?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.451737 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO