2011-07-07 51 views
1

我在我的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.

如何解決此問題?

+2

爲什麼不直接將XML存儲爲字符串,而是將其存儲爲序列化的XmlDocument類? – mdm

+0

[C#:wcf返回一個XmlDocument?]的可能重複(http://stackoverflow.com/questions/964870/c-wcf-return-an-xmldocument) –

回答

-1

有相同的問題,並通過將包含XML文檔的屬性/字段標記爲NonSerializable來解決它。