Visual Studio 2008 应用程序设置未保存?
我知道:
应用程序设置可以存储为任何可 XML 序列化的数据类型或具有实现 ToString/FromString 的 TypeConverter。最常见的类型是字符串、整数和布尔值,但您也可以将值存储为颜色、对象或连接字符串。
我有一个 ListDictionary 类设置 - 它是可序列化的,但每次我再次启动我的应用程序时,尽管创建、分配并将 ListDictionary 保存到我的设置,它仍然为空:
Properties.Settings.Default.Preferences = new System.Collections.Specialized.ListDictionary();
Properties.Settings.Default.Preferences.Add(1, "test");
Properties.Settings.Default.Save();
如何使用这样的类作为应用程序设置?我需要一个字典类型集合作为设置......
I know:
Application settings can be stored as any data type that is XML serializable or has a TypeConverter that implements ToString/FromString. The most common types are String, Integer, and Boolean, but you can also store values as Color, Object, or as a connection string.
I have a ListDictionary class setting - which is serializable but everytime I start up my app again it is null despite creating, assigning and saving a ListDictionary to my settings:
Properties.Settings.Default.Preferences = new System.Collections.Specialized.ListDictionary();
Properties.Settings.Default.Preferences.Add(1, "test");
Properties.Settings.Default.Save();
How can I use such a class as an application setting? I need a dictionary type collection as a setting...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我希望你尝试一些事情。
http://msdn.microsoft.com/en-我们/library/aa730869(v=vs.80).aspx
将 2 个字符串(DictionaryKey 和 Dictionaryvalue)添加到设置中,并将范围设置为 user 并将值设置为空白
进行 2 个设置并执行此操作
当您检索值时
使用此代码:
问候,
Vivek Sampara
There are a set of things i would like you to try.
http://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx
add 2 strings(DictionaryKey and Dictionaryvalue) to the settings and set the scope as user and value as blank
make 2 sting settings and do this
And when you are retrieving the values
use this code:
Regards,
Vivek Sampara