Is there a way to make serializable an object at runtime? Should I use Reflection?
Note: the object is part of an external library, so I do not have the source code for it.
tl;dr - No.
While you can use TypeDescriptor to add attributes to anything at runtime, in the context of the Serializable attribute it won't help since BinaryFormatter uses classic reflection and not TypeDesciptor reflection.
The idea behind that attribute is for the serializable class to opt-in to being serializable. More details about this here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With