'System.Xml.XmlDocument'无法序列化
问题描述:
我在我的C#应用程序中使用AppFabric缓存。我试图缓存一个XmlDocument,但得到以下错误:'System.Xml.XmlDocument'无法序列化
Type 'System.Xml.XmlDocument' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.
如何解决此问题?
答
有相同的问题,并通过将包含XML文档的属性/字段标记为NonSerializable来解决它。
为什么不直接将XML存储为字符串,而是将其存储为序列化的XmlDocument类? – mdm
[C#:wcf返回一个XmlDocument?]的可能重复(http://*.com/questions/964870/c-wcf-return-an-xmldocument) –