Resolved System.Configuration.ConfigurationManager on linux not seeing ./App.config or ./app.config in local directory

lknite

New member
Joined
Oct 10, 2021
Messages
3
Programming Experience
10+
Everything works on windows but when running inside a linux container the config is seemingly not being read, ConfigurationManager is returning empty values. Is the path different on linux?

c#, .net 5.0, up-to-date visual studio 2019, publishing with options Release / net5.0 / Self-contained / linux-x64

- not a permission issue, currently running as root to eliminate this as a variable
- i can exec into the container and see the config files are present and contain the expected data
- i've tried the following names in the same folder as the binary being executed, they all have the values i would expect ConfigurationManager to use, none seem to be loaded:
-- app.config
-- App.config
-- myappname.config
-- MyAppName.config
-- myappname.dll.config
-- MyAppName.dll.config
 
Last edited:
This post is for .NET Core 3.0, but it may still apply in .NET 5:

 
Thank you skydiver.

For others to find later, looks like ConfigurationManager used in this way is deprecated, I switched to this technique:
Configuration.GetSection("appSettings")["marketWSS"], and used the appsettings.json instead.

Which involved the use of Dependency Injection (DI) in my webapi to get access to the IConfiguration.
 

Latest posts

Back
Top Bottom