Sometimes in .NET (2.0) WinForm desktop apps which use the default configuration system, the user.config
file will become corrupted and can't be loaded anymore (when the configuration system tries to load it, it'll throw a System.Xml.XmlException
).
Putting aside the question of "why did the file get corrupted in the first place" (maybe it was cosmic rays, or HDD problems, or something else you can't control), the question then becomes "how can one catch this exception and do something meaningful with it?
Microsoft's Connect site has a report on this sort of problem. Unfortunately, their report isn't very helpful.
Is it possible to catch exceptions that originate in the default configuration system loader itself? Or would you have to roll your own configuration system to be able to catch this type of exception?