Net4x.Configuration.Library
2.5.0.26287
dotnet add package Net4x.Configuration.Library --version 2.5.0.26287
NuGet\Install-Package Net4x.Configuration.Library -Version 2.5.0.26287
<PackageReference Include="Net4x.Configuration.Library" Version="2.5.0.26287" />
<PackageVersion Include="Net4x.Configuration.Library" Version="2.5.0.26287" />
<PackageReference Include="Net4x.Configuration.Library" />
paket add Net4x.Configuration.Library --version 2.5.0.26287
#r "nuget: Net4x.Configuration.Library, 2.5.0.26287"
#:package Net4x.Configuration.Library@2.5.0.26287
#addin nuget:?package=Net4x.Configuration.Library&version=2.5.0.26287
#tool nuget:?package=Net4x.Configuration.Library&version=2.5.0.26287
Net4x.Configuration.Library
A library for reading and writing application settings. It gives one key/value view over
several sources: XML .config files, JSON files, URI query strings, environment variables
and Microsoft.Extensions.Configuration. It targets .NET Framework 3.5 and later as well as
.NET Standard 2.0.
Installation
dotnet add package Net4x.Configuration.Library
Target frameworks: net35, net40, net45, net461, netstandard2.0.
Reading settings with ArgumentGetter
ArgumentGetter.Instance is a process-wide entry point. By default it reads from the entry
assembly's configuration.
using ConfigurationLibrary.Arguments;
var culture = ArgumentGetter.Instance["Culture"]; // string, "" when missing
int? retries = ArgumentGetter.Instance.IntegerFromArguments["Retries"];
bool? verbose = ArgumentGetter.Instance.BooleanFromArguments["Verbose"];
Settings in environment variables are merged into the same dictionary, so
ArgumentGetter.Instance["USERNAME"] works without extra setup.
Choosing the source
using ConfigurationLibrary.Configuration;
// Read <assembly>.json instead of <assembly>.config
ArgumentGetter.Instance.BaseConfigType = typeof(IJsonConfig);
// Point at another file (resolved as <Location>.config / <Location>.json)
ArgumentGetter.Instance.Location = "AppSeparated";
| Interface | Source | Example file |
|---|---|---|
IAppConfig |
XML appSettings (the file="…" attribute is honoured) |
MyApp.exe.config |
IJsonConfig |
JSON with an appSettings object |
MyApp.json |
IUriConfig |
Query string of a Uri |
http://host?One=1&Two=2 |
JSON layout:
{
"appSettings": {
"One": "1",
"Plugin": "exe|My.Namespace.Processor|My.Assembly"
}
}
Reading from a stream
ArgumentGetter.Instance.BaseConfig.Stream = myStream;
try
{
var value = ArgumentGetter.Instance["One"];
}
finally
{
// The configuration is process-wide, so detach the stream when you are done.
ArgumentGetter.Instance.BaseConfig.Stream = null;
}
Typed values from Microsoft.Extensions.Configuration
var configuration = new ConfigurationBuilder().AddJsonFile("config.json").Build();
ArgumentGetter.Instance.Configuration = configuration;
var folders = ArgumentGetter.Instance
.GetFromArgument<Dictionary<string, string>>("Data:TargetFolderLocations");
// or use a getter typed for the target
var typed = ArgumentGetter<Dictionary<string, string>>.Instance;
typed.Configuration = configuration;
var sameFolders = typed.FromArguments["Data:TargetFolderLocations"];
Working with a configuration directly
AppConfig, JsonConfig and UriConfig expose shared instances through Instance, and
standalone ones through CreateNewInstance():
using ConfigurationLibrary.Configuration.Xml;
var config = AppConfig.Instance;
config.Location = typeof(Program).Assembly.Location;
int? port = config.GetIntegerValue("Port");
DateTime? since = config.GetDateValue("Since", "yyyy-MM-dd");
config["LastRun"] = DateTime.Now.ToString("O");
config.Save();
using ConfigurationLibrary.Configuration.Uri;
UriConfig.Instance.CurrentUri = new Uri("http://localhost?One=1&Plugins=a|b|c");
Where Save() writes
Save() does not overwrite the file shipped with the application. It writes a per-user copy
to %USERPROFILE%\<AssemblyCompany>\<file name>.config (or .json). When the entry assembly
has no AssemblyCompany attribute, its name is used instead. On the next load, that copy is
merged over the shipped file.
AllSettings environment variable
Several settings can be passed in one environment variable called AllSettings, as
key=value pairs joined by ArgumentGetter.Instance.Separator:
AllSettingsHelper.PutAllSettingsInArgumentGetter();
Other utilities
StringsHelper.Instance:FirstNonEmptyString,MakeCamelPascalCaseHttpUtility: URL decoding that also works on .NET Framework 3.5/4.0"...".TryParseJson<T>(out var result): JSON parsing that returnsfalseinstead of throwingAppConfigFactory.Instance: the factory behind every shared configuration instanceAppConfigFactoryVariables.Instance.DefaultIsCaseSensitive: key case sensitivity (defaulttrue)
Related packages
Net4x.Configuration.Interfaces: the contracts this library implementsNet4x.Configuration.Crypt: encrypts and decrypts configuration values
Copyright (c) Piero Viano. All rights reserved. Authors: Piero Viano
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net35 is compatible. net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 3.5
- Net4x.BaseTypes (>= 1.3.1.26284)
- Net4x.Configuration.Interfaces (>= 2.5.0.26287)
- Net4x.CoreLibrary.Base (>= 2.5.0.26286)
- Net4x.CoreLibrary.Logging (>= 2.5.0.26286)
- Net4x.CoreLibrary.Threads (>= 2.5.0.26286)
- Net4x.Extensions.Configuration.Binder (>= 2.5.0)
- Net4x.StandardTypesWrappers (>= 1.2.0.26286)
-
.NETFramework 4.0
- Net4x.BaseTypes (>= 1.3.1.26284)
- Net4x.Configuration.Interfaces (>= 2.5.0.26287)
- Net4x.CoreLibrary.Base (>= 2.5.0.26286)
- Net4x.CoreLibrary.Logging (>= 2.5.0.26286)
- Net4x.CoreLibrary.Threads (>= 2.5.0.26286)
- Net4x.Extensions.Configuration.Binder (>= 2.5.0)
- Net4x.StandardTypesWrappers (>= 1.2.0.26286)
-
.NETFramework 4.5
- Net4x.BaseTypes (>= 1.3.1.26284)
- Net4x.Configuration.Interfaces (>= 2.5.0.26287)
- Net4x.CoreLibrary.Base (>= 2.5.0.26286)
- Net4x.CoreLibrary.Logging (>= 2.5.0.26286)
- Net4x.CoreLibrary.Threads (>= 2.5.0.26286)
- Net4x.Extensions.Configuration.Binder (>= 2.5.0)
- Net4x.StandardTypesWrappers (>= 1.2.0.26286)
-
.NETFramework 4.6.1
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0)
- Net4x.BaseTypes (>= 1.3.1.26284)
- Net4x.Configuration.Interfaces (>= 2.5.0.26287)
- Net4x.CoreLibrary.Base (>= 2.5.0.26286)
- Net4x.CoreLibrary.Logging (>= 2.5.0.26286)
- Net4x.CoreLibrary.Threads (>= 2.5.0.26286)
- Net4x.StandardTypesWrappers (>= 1.2.0.26286)
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0)
- Net4x.BaseTypes (>= 1.3.1.26284)
- Net4x.Configuration.Interfaces (>= 2.5.0.26287)
- Net4x.CoreLibrary.Base (>= 2.5.0.26286)
- Net4x.CoreLibrary.Logging (>= 2.5.0.26286)
- Net4x.CoreLibrary.Threads (>= 2.5.0.26286)
- Net4x.StandardTypesWrappers (>= 1.2.0.26286)
NuGet packages (45)
Showing the top 5 NuGet packages that depend on Net4x.Configuration.Library:
| Package | Downloads |
|---|---|
|
Net4x.UtilityLibrary
Package Description |
|
|
Net4x.IoCLibrary
Package Description |
|
|
Net4x.DataAccessLibrary.Classes
Package Description |
|
|
Net4x.DapperLibrary.Pivot
Package Description |
|
|
Net4x.WindowsFormsLibrary
Windows Library |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.5.0.26287 | 57 | 10/15/2026 |
| 2.5.0.26236 | 6,697 | 8/24/2026 |
| 2.5.0.5 | 2,266 | 7/17/2026 |
| 2.5.0.4 | 1,232 | 2/2/2026 |
| 2.5.0.3 | 716 | 1/23/2026 |
| 2.5.0.2 | 929 | 1/5/2026 |
| 2.5.0.1 | 644 | 12/30/2025 |
| 2.5.0 | 2,055 | 11/9/2025 |
| 1.6.0 | 6,066 | 3/31/2025 |
| 1.3.0 | 8,552 | 8/26/2023 |
| 1.3.0-at20230505032208 | 7,272 | 5/7/2023 |