Get values and sections from app.config
How do I get the values from the .NET Framework app.config or web.config file?
10 Replies
I'd suggest reading https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/read-app-settings
How to: Read application settings - .NET Framework
Learn how to read application settings from an app.config file in .NET Framework.
There's also a nice stack overflow post about this: https://stackoverflow.com/questions/1189364/reading-settings-from-app-config-or-web-config-in-net
Stack Overflow
Reading settings from app.config or web.config in .NET
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 Wind...
oh thanks, im trying to setup this in my lib
yea, lib is a bit more complex
but there is a section in the docs about them
yeah, that's why I feel like I need help, basically I want to make a global configuration so that when I instantiate an object from the main class of my lib it gets the information from the .config
is that information provided by users of the library, or by the library?
by the users
they can add it to their app.config if you're comfortable with that
otherwise something like this:
mplement a custom section type that extends the ConfigurationSection class. Keep a separate configuration file for your class library, and then reference the library's configuration file from the client app's configuration file. For more information, see How to: Create Custom Configuration Sections Using ConfigurationSection.
I'll give it a read
Any difficulties, can I post here?
absolutely