Properties Settings will not be saved.

I am trying to save two custom values ​​(SliderWidth and SliderHeight). I want to do this with the settings of the Visual Studio settings.

The Visual Studio option settings

When I debug this with this code:

public void Test(int value) { Properties.Settings settings = Properties.Settings.Default; settings.SliderWidth = value; settings.Save(); } 

The values ​​do not change (after the end of the program).

What's wrong?

+4
source share
2 answers

It definitely works. Try the following:

 public void Test(int value) { Properties.Settings settings = Properties.Settings.Default; MessageBox.Show("Last SliderWidth = " + settings.SliderWidth.ToString()); settings.SliderWidth = value; settings.Save(); } 

But the saved value will not be displayed in the designer window, which you show in the screenshot. These are the initial defaults.

+2
source

If your AssemblyInfo.cs has * in the Assembly version, it will reset this file every time. Try hard coding the last number. Clean and rebuild everything and it should work fine.

0
source

Source: https://habr.com/ru/post/1416151/


All Articles