Managing errors while loading App.config
am 21.01.2008 17:34:01 von FutronicsDeveloperI am using 'Settings' (the auto-generated Properties.Settings) and
ConfigurationSection derived classes in my application.
If my configuration file (app.config) gets corrupted (or the user changes it
incorrectly) then I would like my application to pick up settings defaults
and not to keep trying to load from the config file, and hence create an
exception, each time.
Both the auto-generated Properties.Settings and ConfigurationSection derived
classes have defaults. What I'm currently getting is an exception every time
I reference one of these settings if the config file is corrupted.
If the config file is corrupted I would like to somehow set the
ConfigurationManager to an empty or null app.config file so that all
subsequent configuration settings calls will return defaults and won't keep
generating exceptions each time.
The application runs fine on defaults and is much better to do this than to
just terminate.
Does anyone know if this is possible?