I have a Class Library that I'm converting to a .Net Standard 2 class library in order to also use in ASP.Net Core 2.0 projects.
The library has always read from a config file items such as SMTP settings, connection strings etc.
In Web Projects it finds these values in web.config.
In Console/WinForms it finds these values in app.config.
Is there an equivalent config file for .Net Core 2.0 projects that "just works" like the previous examples?
I assume the answer is no, but looking for best way to handle this given the library is used across the organization, so maintaining backwards compatibility is important.
NET Standard 2.0, unless you need to support an earlier version. Most general-purpose libraries should not need APIs outside of . NET Standard 2.0. . NET Standard 2.0 is supported by all modern platforms and is the recommended way to support multiple platforms with one target.
Machine configuration files config, contains settings that apply to an entire computer. This file is located in the %runtime install path%\Config directory. Machine. config contains configuration settings for machine-wide assembly binding, built-in remoting channels, and ASP.NET.
Broad platform support. . NET Standard 2.0 is supported on the following platforms: . NET Framework 4.6.
Configuration files are standard XML files that you can use to change settings and set policies for your apps. The . NET Framework configuration schema consists of elements that you can use in configuration files to control the behavior of your apps.
Turns out System.Configuration.ConfigurationManager was added back in .NETStandard 2.0.
Just pull it in from nuget and compile the .NETStandard 2.0 class library project.
Then, the library will work across projects using standard config files:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With