title: How to catch exception when loading .NET WinForm app user.config file?
body: <p>Sometimes in .NET (2.0) WinForm desktop apps which use the default configuration system, the <code>user.config</code> file will become corrupted and can't be loaded anymore (when the configuration system tries to load it, it'll throw a <code>System.Xml.XmlException</code>).</p>
  
  <p>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?</p>
  
  <p><a href="http://connect.microsoft.com/VisualStudio/feedback/details/497189/user-config-file-corruptions-will-cause-exceptions-that-are-unrecoverable" rel="nofollow noreferrer">Microsoft's Connect site has a report on this sort of problem</a>. Unfortunately, their report isn't very helpful.</p>
  
  <p>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?</p>