Is there a way to just tell the compiler, that I want my objects to be serializable by default?
From stackoverflow
-
No, you need to decorate the objects with the Serializable attribute. FYI all objects are Xml Serializable by default. The Xml Serializer doesn't require the attribute.
I'm not sure about DataContracts but last I checked you needed to decorate them as well.
-
Pretty much every serialization engine is going to want to know that your objects are suitable. This can take the form of:
[Serializable]/ISerializable(BinaryFormatter,SoapFormatter)[Serializable]/IXmlSerializable(andpublic) (XmlSerializer)[DataContract]/[MessageContract](or most of the above) (DataContractSerializerand variants)
AFAIK, there is no way of avoiding this step.
0 comments:
Post a Comment