Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6340789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:54:10+00:00 2026-05-24T19:54:10+00:00

Sometimes in .NET (2.0) WinForm desktop apps which use the default configuration system, the

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:54:10+00:00Added an answer on May 24, 2026 at 7:54 pm

    Turns out you can catch this exception. The hint I needed came from this question:

    C# – User Settings broken

    In my case, (WinForms app), the exception handler I have in my parent (startup) form catches this exception. But I suppose you could use the MyApplication_UnhandledException handler in ApplicationEvents as well. Bottom line is, you need some sort of high-level “unhandled exception” handler to catch this.

    Additionally, you can look at the exception’s InnerException and see if it is of type System.Configuration.ConfigurationErrorsException. If it is, then you can look at the .FileName property of this InnerException to get the full file name of the user.config file.

    Once you have this, you can do something about it – try to check its contents to see what’s wrong with it, or (worst case) delete it and restart the app so it is re-created with all the default settings.

    As I said before, this is a very rare exception, probably caused by sudden system shutdowns or other uncontrollable events (e.g., power outage). Nevertheless, it is nice to finally be able to do something about it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes it will be a SocketException: Stack trace: at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32
I am using .NET Remoting. My server/hoster is a Windows Service. It will sometimes
We use ERPConnect in our ASP.NET application but sometimes we get some error messages
I have built a Library project (DLL) in .NET. And sometimes I use the
Sometimes the .NET runtime requires us to create public setters for properties which should
I have a .Net page with some textboxes, which are sometimes disabled. <asp:TextBox ID=TextBox1
Sometimes I do despair when working with ASP.Net - another problem that shouldn't be!
ASP.NET tracing seems very erratic. Sometimes it traces and sometimes it doesn't. I trace
Sometimes (pretty rarely) when I connect to a running instance of a com.sun.net.httpserver.HttpServer I
On an ASP.NET MVC (Beta) site that I am developing sometimes calls to ActionLink

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.