1

I'm trying to use properties.settings for the first time in a C# WPF project.

I have this code:

Settings.Default.comPort = "";
Settings.Default.baudRate = 9600;
Settings.Default.startUp = false;
Settings.Default.taskBar = true;
Settings.Default.desktopNotif = false;
Settings.Default.reset = false;
Settings.Default.Save();  

But it didn't work and the settings wasn't saved. So I added this line

Console.WriteLine("test");

after that part, to check if it goes through the code, and it executed fine.
So It seems that it just jumps over those lines without execution or even throwing any exceptions.

4

1 回答 1

2

感谢Panagiotis Kanavos,我终于找到了问题所在。代码是正确的,但是当程序在 Visual Studio 中运行时,每次设置都会被覆盖。构建后,我.exe filebin/release文件夹中运行它,它工作得很好。

于 2016-03-21T12:34:12.103 回答