Hello, the problem is this. Create an XML file App.config in the application folder as follows

<?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="1" value="2" /> </appSettings> </configuration> 

Then in the program I want to see the number of pairs (key / value):

 Console.WriteLine(ConfigurationManager.AppSettings.Count) 

Displays 0 for some reason, but not 1. Tried to create more pairs, all the same 0 is issued. Thank you in advance.

  • one
    Did the same thing - displays the correct amount. - wind
  • one
    And you can also access ConfigurationManager.AppSettings ["1"] without any exceptions? - nvse

1 answer 1

In general, I do not know what the problem was, again I added the App.config machine again, but via Visual Studio directly, and not through the explorer, manually creating the file. Perhaps it was all about it.

  • one
    Yes, I added it with the help of the studio. Perhaps with this approach, the studio writes somewhere about the existence of such a config for the application, and therefore the manager and everyone else sees it. - wind