0

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!

Martin
  • 1,986
  • 15
  • 32
  • 1
    When looking for the cause for very basic broken functionality, *never* start by assuming there's a bug in a class that's used by a million programmers. – Hans Passant Jan 25 '13 at 13:47
  • And along the same lines that Hans mentioned, have you specifically tried to reproduce this at the most simplistic level? That is, have you actually performed something like your sample above and verified that's where the problem is? – Pete Jan 25 '13 at 14:13
  • If you put a breakpoint right before the second call to `Save`, is the value of `Y` correct? If not, it's very likely that something in your code is changing it. As Hans Passant pointed out, it's highly unlikely that the `ApplicationSettings` class is failing in a fundamental way. – Jim Mischel Jan 25 '13 at 14:15
  • @HansPassant: I totally agree with you. But because I did not _start_ by assuming this, I dared to ask. Thus, may I assumes your experiences with this class are good? – Martin Jan 25 '13 at 14:26
  • @Pete: Yes. Currently cannot reproduce with a simple program. Still investigating. – Martin Jan 25 '13 at 14:27
  • @JimMischel: Yes. BTW, simply commenting the first save will make it work. – Martin Jan 25 '13 at 14:31

0 Answers0