Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a universal config file for .Net Standard 2.0 Class Library?

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.

like image 690
Brad Bamford Avatar asked Nov 14 '17 19:11

Brad Bamford


People also ask

Is .NET standard 2.0 still supported?

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.

Where is .NET configuration file?

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.

Is .NET standard 2.0 compatible with .NET framework?

Broad platform support. . NET Standard 2.0 is supported on the following platforms: . NET Framework 4.6.

What are the configuration files used by the .NET framework?

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.


1 Answers

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:

  • Net Core 2.0 projects use app.config
  • Web projects work from web.config
  • Console and Windows apps work with app.config
like image 170
Brad Bamford Avatar answered Sep 21 '22 15:09

Brad Bamford