问题
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