Karl Sangree
Karl Sangree

Reputation: 111

Error accessing my.settings - corrupt user.config

I have a client who has asked me to fix a problem with a corrupt user.config file. The config file has enough of an XLM header for the program to load the settings, but the rest of the config file is nulls (0x00) so the config loads, but then an error occurs when attempting to access any of its member. Note: the 0x00 value pops up in the error message later.

After much research, the common suggested solution seems to be delete the user.config file and then do a My.Settings.Reset but this doesn't work for me. The only solution that seems to work is to delete the user.config file, and then shut down and restart the program. The program starts and runs fine after deleting the user.config file. It creates a new user.config with default values and goes on its merry way with no problems.

What I have tried: First:

Dim innerExcept As ConfigurationErrorsException = CType(cex.InnerException, ConfigurationErrorsException)
My.Computer.FileSystem.DeleteFile(innerExcept.Filename)

Then various combinations of the following:

My.Settings.Reset()
My.Settings.Reload()
My.Settings.Upgrade()

No matter what I try, I get the following error. Any thoughts?

System.Configuration.ConfigurationErrorsException HResult=0x80131902 Message=Configuration system failed to initialize

[truncated for brevity]

Inner Exception 1: ConfigurationErrorsException: '.', hexadecimal value 0x00, is an invalid character.

Upvotes: 0

Views: 444

Answers (0)

Related Questions