开发者

WCF serializing error - 'System.Net.Mail.MailAddress' cannot be serialized

Please help me with this WCF error....How do I handle these builtin classes for WCF?

Type 'System.Net.Mail.MailAddress' cannot be serialized. Consider marking it with the DataContractAttribute att开发者_高级运维ribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. See the Microsoft .NET Framework documentation for other supported types.


You could implement a surrogate that knows how to de(serialize) the MailAddress type.


Create a custom class which contains all the data / properties that you need from MailAddress to transport across the wire and then map the MailAddress to this custom class. You'll need to do the opposite on the client. If you keep the same property names / class hierarchy, a tool like AutoMapper could reduce coding in the to / from mapping.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜