简体   繁体   中英

user.config corruption issue

In our desktop application projects we use setting variables to store user setting for the applications. Moreover, with every latest version of the applications, we upgrade these variables to retain user settings.

Normally, this works fine, but recently one of my end user reported an error ie Configuration System failed to initialize . The error is related to user.config file. Therefore we requested the user to send us his file.

After received the folder, we noticed that it contains 3 files ( c3begfjb.newcfg , c3begfjb.tmp and user.config ). c3begfjb.tmp is an empty file, while c3begfjb.newcfg and user.config are identical files. We tried to open these files but the data in user.config isn't proper xml rather its unreadable formatted file.

Do any you guys had experienced this sort of issue or any ideas how and what may have created these files and corrupted user.config file.

                try
                {
                    // preloads the settings file and throws an error if the settings file is corrupted
                    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                }
                catch (ConfigurationErrorsException ex)
                {
                   File.Delete(ex.Filename);
                }

This article may be helpful.

https://www.codeproject.com/Articles/30216/Handling-Corrupt-user-config-Settings

Basically the process is to check if config is not corrupted, if not, it resets config.

This is the solution I did it to fix the configuration file for my setting

https://stackoverflow.com/a/70191760/11406286

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM