Application Settings scope - user vs application

北慕城南 提交于 2021-02-19 12:53:36

问题


If I create a user level application setting and bind it to a text box on a form, then type something in the textbox, the value is automatically saved and when the application is launched again the value appears in the textbox. This doesn't happen when I scope the setting as application.

Why are application scoped settings not saved automatically like user scoped settings are?

If this is by design, how can I manually save these settings and load them at runtime?


回答1:


In short, application scoped settings can't be changed at runtime while user scoped settings are designed be read/written at runtime. There are a number of alternatives to using application scoped settings:

  • Use user scoped settings
  • This post recommends looking into the ConfigurationManager class.
  • If you don't like user scoped settings because they are not written to the application directory you can implementing your own SettingsProvider and have them written where ever you'd like

This post has some recommendations on how to best manage settings. Finally, here is Microsoft's documentation on the settings architecture if you're interested in extending theirs or rolling your own.



来源:https://stackoverflow.com/questions/10145955/application-settings-scope-user-vs-application

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