Make an object serializable at runtime
2 answers
tl; dr - No.
While you can use TypeDescriptor
to add attributes to anything at runtime, in the context of an attribute Serializable
it won't help as it BinaryFormatter
uses classic reflection, not TypeDesciptor
reflection.
The idea behind this attribute is that the class being serialized can be serializable. More on this here .
+3
source to share
Depending on the structure, you can use a serializer that doesn't pick, i.e. it does not require any attribute on the target class like XmlSerializer or JavaScriptSerializer .
0
source to share