将文档序列化到IsolatedStorage中。 XMLSerializer 到底在哪里?

发布于 2024-10-06 08:11:29 字数 819 浏览 1 评论 0原文

在进行彻底的 Web 浏览后,我看到了两种在 Windows Phone 7 中序列化内容以将其输入isolatedStorage 的方法。我正在使用 VisualStudio 2010,以及 Silverlight 的 11 月更新,这是一个典型的 WP7 应用程序,基于 Panorama,但这并不重要。它们都需要几个“using”子句,然后进行序列化并存储文件。

在其中一种方法中,这种方法看起来更容易,并且对我尝试序列化的类的干扰更少,但我在序列化部分遇到了问题。 XMLSerializer 似乎不存在于 System.Xml.Serialization 命名空间中。这是以前存在但现在不复存在的东西吗?下面是一个页面示例,似乎假设存在 XmlSerializer:

http://fatsweb.blogspot.com/2010/11/tombstoning-in-phone-7-xna-games.html

请注意,这是 11 月的帖子,因此相当新。它是否适用于 XNA 应用程序而不适用于 Silverlight 应用程序?无论如何,在我的 VS2010 XmlSerializer 中,我遇到了可怕的“找不到类型或命名空间”错误,并且即使在添加“using System.Xml.Serialization;”之后也没有解决方案。手工。有什么想法吗?

一种替代答案似乎是使用 DataContractSerializer,但这将涉及对我的自定义类的大量干扰,在类本身中输入用于序列化的各种信息。如果可能的话我宁愿避免这种情况。

After doing some thorough web browsing, I've seen two methods for serializing stuff in Windows Phone 7 to enter it into IsolatedStorage. I'm using VisualStudio 2010, with the November update for Silverlight, and this is a typical WP7 app, Panorama-based, not that this matters. They both need a couple of "using" clauses, then go through serialization and store the files.

In one of these methods, the one that seems easier and involve less meddling with the class I'm trying to serialize, I'm facing problems at the serialization part. XMLSerializer seems to not be there in the System.Xml.Serialization namespace. Is this something that used to be there and is no more? Here's an example of page that seems to assume that XmlSerializer is there:

http://fatsweb.blogspot.com/2010/11/tombstoning-in-phone-7-xna-games.html

Note that this is a November post, so it's fairly new. Is it that maybe it's there for XNA apps and not for Silverlight apps? In any case, in my VS2010 XmlSerializer gives me the dreaded "type or namespace cannot be found" error and no options for resolving even after adding "using System.Xml.Serialization;" by hand. Any ideas where the heck this is?

One alternative answer seemed to be using the DataContractSerializer, but that would involve lots of meddling with my custom classes, entering all kinds of information for serialization in the class itself. I'd rather avoid that if possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鲜血染红嫁衣 2024-10-13 08:11:29

在 Silverlight 中(因此在 Phone 上也是如此),此类位于不同的程序集中(默认情况下不引用)。

您需要添加对 System.Xml.Serialization.dll 的引用才能使用它。

但是,请注意 XML 序列化速度很慢。强烈考虑使用其他东西。

不同可用选项性能的快速总结:
- 二进制最适合大数据。比 JSON 和 XML 快得多。
- JSON.NET 比框架中的 JSON 序列化器更快。
- XML 是最慢的。

In Silverlight (and therefore on the Phone too) this class is in a different assembly (not referenced by default).

You'll need to add a reference to System.Xml.Serialization.dll to be able to use it.

However, be aware that XML serialization is slow. Strongly consider using something else.

A quick summary of the performance of the different options available:
- Binary is best for large data. Much faster than JSON and XML.
- JSON.NET is faster than the JSON serializer in the framework.
- XML is the slowest.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文