If I update a value in settings.settings, the code in the settings.designer file changes for the default value. However in my build I have the app.debug.config and app.live.config versions which I want to copy over to the app.config (active) configuration, which holds the relevant app config data. Therefore the settings file defaults are irrelevant.
What I found out was that the default in the settings file overrides the app.config. So I set the ‘GeneratedDefaultValueInCode’ to false. I thought this would mean the app.config would contain the active setting. But when I deployed my app, low and behold the setting is blank!
What’s the point of having 2 locations to store the same data then? Whats the point of even having an app.config file if the settings file is used?
How do I ensure when I use the settings properties in the code, the default setting is read from the app.config?
If you look at the codebehind for Settings.Settings, you will see the ‘default value’ that is shown is actually the value stored in app.config, and is being loaded from app.config- the value is not stored in Settings.settings itself nor in its codebehind.
I’m not sure how you have the app.debug.config and app.live.config setup, but as long as at runtime the APPNAME.exe has a matching APPNAME.config it will load off of it, including APPNAME.vshost.exe having a matching APPNAME.vshost.config
It is also possible for you to read directly from your appconfig using
ConfigurationManager