HttpWebRequest Won't Serialize

后端 未结 2 869
别跟我提以往
别跟我提以往 2021-01-21 11:22

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

Type \'System.Net.KnownHttpVerb\' in Assembly \'System, Version=2.0.0.0, Cu

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-21 11:28

    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.

    EDIT: There's a fairly good article on it here.

    EDIT2: 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).

提交回复
热议问题