Mono doesn't write settings defaults

旧城冷巷雨未停 提交于 2020-01-03 10:19:22

问题


Here is my problem. If I use only one Windows Forms project and call only - Settings.Default.Save() when running it, Mono creates a user.config file with the default value for each setting. It is fine, so far so good.

But now I add a class library project, which is referenced from the Windows Forms project and I move the settings from the Windows Forms project to the Class Library one. Now I do the same - Settings.Default.Save() and to my great surprise, Mono creates a user.config file with EMPTY values(NOT the default ones) for each setting?! What's the difference between having the settings in the Windows Forms Project or in the class library one? And by the way it is not a operating system issue. It is a Mono issue, because it doesn't work both under Windows and Linux. If I don't use Mono everything is fine, but I have to port my application to Linux, so I have to use Mono. I am really frustrated, it is blocking a project:(

Edit: If I write Settings.Default.Font = Settings.Default.Font; before calling the Settings.Default.Save(), then it is working properly. What is this?!

Thanks in advance for any suggestion you have.

Regards, Petar


回答1:


OK, in case someone else enters into this dreadful issue, I managed to workaround it this way:

Settings.Default.MySetting1 = Settings.Default.MySetting1;
Settings.Default.MySetting2 = Settings.Default.MySetting2;
.........................................................
Settings.Default.MySettingN = Settings.Default.MySettingN;

I execute this code when my application is starting.




回答2:


From a mono developer "if someone files a bug, I can fix it more or less soon ;-)". It looks like a trivial fix, just file all the above information at http://bugzilla.novell.com and someone will be able to take a look at it. If you include a small testcase which demonstrates the bug that'd be ideal as it can be added to the testsuite to prevent this ever breaking again.



来源:https://stackoverflow.com/questions/2583606/mono-doesnt-write-settings-defaults

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