.NET: ApplicationSettingsBase unreliable?

爱⌒轻易说出口 提交于 2019-12-12 03:44:50

问题


In a larger application that makes use of Application Settings, sometimes some settings are not saved.

When the following code is executed, everything works fine:

Properties.Settings.Default.SomeSetting.X = 42;
Properties.Settings.Default.SomeSetting.Y = true;
Properties.Settings.Default.Save();

But this code

Properties.Settings.Default.SomeSetting.X = 42;
Properties.Settings.Default.Save();
Properties.Settings.Default.SomeSetting.Y = true;
Properties.Settings.Default.Save();

does call the getter of Y during the first call to Save(), but not during the second call to Save(), and the value of Y will not change in the XML file written.

The code of course is more complicated, the settings are far more complicated, and the statements are not just right one after the other, but it basically works like this. I tried to reproduce this with a simple program, but did not succeed (yet?).

BTW: The settings file always gets written correctly. There are no exceptions, handled or unhandled.

I'm still investigating, however I wanted to ask you: Is ApplicationSettingsBase working reliably? Any experiences with this?

Thank you!

来源:https://stackoverflow.com/questions/14522666/net-applicationsettingsbase-unreliable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!