Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top