Re: Managing errors while loading App.config by Alvin
Alvin
Mon Jan 21 20:26:34 CST 2008
I don't know if this is possible.
I'd venture a guess that if the configuration file is corrupted should the
application bomb and fall over dead so that the support technician can come
and fix the problem? That should be the driving reason UNLESS the
application must be fault tolerant. If fault tolerance is your goal, you
can't use code to work around this situation because the config file occurs
right after the appdomain for the application is loaded so I suppose its
worth a try to wire the unhandled exception at the app domain level. You'll
still have a problem though because all threads have started to unwind from
the appdomain when that event fires and I'm not sure how you can 'reload'
them.
--
Regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------
"Futronics Developer" <FutronicsDeveloper@discussions.microsoft.com> wrote
in message news:F472D5BB-CCC6-4076-813D-5B379A91A3DF@microsoft.com...
>I 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?
>
>