WCF 序列化错误 - “System.Net.Mail.MailAddress”无法序列化

发布于 2024-09-10 17:13:08 字数 251 浏览 3 评论 0原文

请帮我解决这个 WCF 错误...我如何处理 WCF 的这些内置类?

无法序列化类型“System.Net.Mail.MailAddress”。考虑 使用 DataContractAttribute 属性对其进行标记,并标记所有 您希望使用 DataMemberAttribute 序列化其成员的数量 属性。有关其他信息,请参阅 Microsoft .NET Framework 文档 支持的类型。

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 attribute, and marking all
of its members you want serialized with the DataMemberAttribute
attribute. See the Microsoft .NET Framework documentation for other
supported types.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

抱猫软卧 2024-09-17 17:13:08

您可以实现一个知道如何反(序列化) MailAddress 类型。

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

烟酒忠诚 2024-09-17 17:13:08

创建一个自定义类,其中包含通过网络传输 MailAddress 所需的所有数据/属性,然后将 MailAddress 映射到此自定义类。您需要在客户端上执行相反的操作。如果保持相同的属性名称/类层次结构,像 AutoMapper 这样的工具可以减少到/从映射中的编码。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文