ConfigurationManager.AppSettings.AllKeys is always empty

  .net-4.8, .net-standard, windows

In my .NET 4.8 Windows app I need to read settings from app.config NOT from project settings. This is part of the requirement and I’m not able to change it.

my app.config is located in default location, alongside my form. When compiled I find bin/debug/project.exe.config (I’m running in debug)

In the config file I have

<setting name="UseFish" serializeAs="String">

And in my codebehind I have

string sUseOCarpIf = System.Configuration.ConfigurationManager.AppSettings["UseFish"];

However this always returns null.

AppSettings.AllKeys is always empty, although there are many entries in the config file.

Source: Windows Questions