本文介绍了HttpWebRequest的不会序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误,当我尝试序列化的HttpWebRequest

I'm getting the following error when I try to Serialize an HttpWebRequest

输入System.Net.KnownHttpVerb  大会'系统,版本= 2.0.0.0,  文化=中立,  公钥= b77a5c561934e089'是  未标记为可序列化。

使用.NET Framework 2.0

Using .Net Framework 2.0

这是我的课持有的属性之一。这是一个要求序列化。

This is one of the properties that my class holds. It's a requirement to serialize it.

HttpWebRequest的被标记为可序列化,因此应该序列化

HttpWebRequest is marked as Serializable so it supposed to Serialize

推荐答案

那么,如果包含的对象之一,被标记为不可序列化,我相信你是运气不好使用默认的序列化。

Well, if one of the contained objects is marked as non-serializable, I believe you're "out of luck" using the default serializer.

如果可能的话,我会建议,而不是采取用实例您的网络请求的参数和序列化,而不是这些。编写自定义的串行/解串器来重建不合作的对象。

If possible, I would recommend instead taking the parameters used to instantiate your web request and serializing those instead.Write a custom serializer/deserializer to reconstitute the uncooperative object.

编辑:有上有一个相当不错的文章这里

There's a fairly good article on it here.

EDIT2:其实,有一点谷歌搜索后,看来这是你唯一的选择,因为在HttpWebRequest的Serializable属性已被标记为已过时,作为.NET 2.0。请参见这里的详细信息(搜索HttpWebRequest的)。

In fact, after a little googling, it appears that this is your only option, as the Serializable attribute on HttpWebRequest has been marked obsolete as of .net 2.0. See here for details (search for HttpWebRequest).

这篇关于HttpWebRequest的不会序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 14:47