tags:

views:

35

answers:

1

Hello,

Can someone guide me towards implementing the IDataContractSurrogate for the MailMessage class in .Net Framework?

I'm currently trying to pass the MailMessage class as an object and it doesn't work...it throws the following exception...

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.

I would appreciate any help...

Thanks so much!!

+2  A: 

Hi Josh,

Actually there's an assumption in the given (Jaroslav's) example that the legacy class (Person) is XmlSerializable (not the case for either MailAddress or MailMessage).

Please check this post for a possible solution.

Best,

casals