当使用los foratter串连化一个mial消息时,我得到以下内容.
错误:Sys.WebForms.PageRequestManagerServerErrorException:错误序列化System.Net.Mail.MailMessage类型为“System.Net.Mail.MailMessage”的值.
解决方法
可惜的是,System.Net.Mail.MailMessage类没有被标记为可序列化.所以,是的,你需要自己去做.以下博客文章中介绍的技术可以让您了解如何继续:
How to Serialize a MailMessage …基本上,您将需要单独拉出每个属性.引用:
To serialize the properties of a MailMessage object you can create a
new class and create a property of MailMessage type for it that embeds
your MailMessage in the class. In this new class you can implement
IXmlSerializable interface to manually serialize its MailMessage. Here
I create this class and call it SerializableMailMessage […][code implementation of WriteXml() and ReadXml() methods follow; see source link]