Corruption of user.config

2019-08-28 10:44发布

问题:

Anyone knows the reason of "random" user.config corruption? I've a WinForms app affected by this problem at my client's production line. Found the same issue on the web and a workaround but I can't figure out because it happens.

回答1:

I'm not sure why it's happening, but you are not alone, dude! I also tried different things to get around this. I wrote my own configuration handling classes with custom serialization. All I can tell you is, it's better but now still there.

One observation I made recently is that the corruption seems to happen when the machine is rebooted (due to Windows Updates for example) while my app is running.

Next thing to try is to catch those shutdown events and try not to write to the config file in this situation.



回答2:

Did you try Properties.Setting.default.reset()?