在 Windows Mobile 应用程序中存储应用程序设置的首选方法是什么?
我正在使用 .NET Compact Framework 3.5,并且试图确定是否有标准方法来存储用户在我的应用程序中更改的设置。我知道 Compact 3.5 SQL 数据库,但我试图避免这种情况,如果可以的话,可以避免用户移动设备上尚未安装的依赖项(我已经不得不担心 3.5 .NET Framework,所以我正在尝试如果可以的话,避免任何其他依赖)。
我发现旧的 .config 文件(通过 System.Configuration.ConfigurationSettings.AppSettings)已过时,而且 Compact 框架似乎不受支持。
除了将其填充到存储在 /Application Data/My App/ 中的 xml 文件中并解析它之外,是否有任何内置库用于此类功能?
我在网上或本网站上没有看到太多关于此的信息。主要是非紧凑框架解决方案。
I am using the .NET Compact Framework 3.5 and I am trying to determine if there is a standard way to store settings that a user to change in my application. I am aware of the Compact 3.5 SQL database, but I am trying to avoid that if I can to avoid a dependency that is not already installed on the user’s mobile device (I already have to worry about the 3.5 .NET Framework so I am trying to avoid any other dependencies if I can).
I saw that the old .config file (via System.Configuration.ConfigurationSettings.AppSettings) is obsolete and doesn’t appear to be supported on the Compact framework anyway.
Aside from stuffing it in an xml file stored in /Application Data/My App/ and parsing it, are there any built in libraries for this type of functionality?
I am not seeing much online or on this site about this. Mostly non-compact framework solutions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我实际上最终使用了 System.Xml.Serialization.XmlSerializer。这使我们能够轻松存储和恢复设置。在进行升级/降级时,它可以容忍对设置的更改。
I actually ended up using System.Xml.Serialization.XmlSerializer. This allowed us to store and restore settings with little effort. It is tolerant of changes to the settings when doing an upgrade/downgrade.
OpenNetCF 支持加载和将设置保存到 xml 文件
OpenNetCF.AppSettings 命名空间,SettingsFile 类应该可以解决这个问题:)
OpenNetCF has support for loading and saving settings to an xml file
OpenNetCF.AppSettings namespace, and the SettingsFile class should do the trick :)
我在应用程序中使用注册表进行许多设置。我们创建了一个围绕注册表调用的包装器,用于处理异常、内存清理等。之后,它运行得很好。我想这一切都取决于您所讨论的设置类型。
I use the registry for many settings in my application. We created a wrapper around registry calls that handle exceptions, memory cleanup, etc. After that, it works pretty well. I guess that all depends on what kind of settings you are talking about.
在测试 OpenNetCF.AppSettings 并尝试从头开始创建配置管理器后,我最终使用 此类。这很简单,而且很有效。
编辑:上面的链接已失效,所以我将类源代码放在这里。
用法:
After testing OpenNetCF.AppSettings and trying to create a configuration manager from scratch, I ended up using this class. It's simple, and it just work.
Edit: the link above is dead, so I put the class source code here.
Usage:
另一个后备选项是老式的 .INI 文件。有许多纯 C# 类可用于解析它们并使用这些值。简单明了。
Another fallback option is good old fashioned .INI files. There's a number of pure C# classes out there for parsing them and using the values. Simple and straightforward.