【发布时间】:2011-03-31 07:59:18
【问题描述】:
我正在尝试序列化 Request 对象以用于日志记录。代码
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(obj.GetType());
// obj is a Request object
给了我以下异常:
To be XML serializable, types which inherit from ICollection must have an implementation of Add(System.String) at all levels of their inheritance hierarchy. System.Web.HttpValueCollection does not implement Add(System.String).
如何解决问题?谢谢。
【问题讨论】:
-
obj 是什么类型?是你的类型吗?
-
在标题中您说您正在尝试序列化 HttpValueCollection,而在描述中您说的是请求(HttpRequest?)。你能更清楚你的问题吗?
标签: c# asp.net httprequest