I want to parse a text message and store in into an object of type System.Net.Mime.Attachment. The problem comes when I want to serialize this object.
Error: Type "System.Net.Mime.ContentType" is not marked as serializable.
How can I avoid this?
Thanks.
You won’t be able to do a simple serialization here because the class itself is not marked with the [Serializable] attribute.
However, after looking at the docs, it looks like the class is really just a helper for constructing and manipulating strings like “text/javascript”. And based on the documentation of the ToString method, you can round trip a ContentType object merely using the ToString method and the constructor.
For Example:
you can do whatever you want with your string above (write it to disk…whatever).