german129
german129

Reputation: 237

Does .net BinaryFormatter support inheritance?

I currently have a socket application that I use to send string back and forth from a client to a server. I recently decided that it would make more sense to send serialized objects instead but ran into a problem. I converted the code to use the SoapFormatter which allowed me to serialize the objects to string and send the string. I ran into an issue on the client side when trying to deserialize inherited objects. It seems that the soapformatter does not support inheritance. The problem occured during deserialization, if i tried to deserialize the parent object when i send the child object (I dont know if this is correct terminology) it would throw a cast exception.

My question is, does the BinaryFormatter support inheritance??

Upvotes: 0

Views: 1116

Answers (1)

svick
svick

Reputation: 245028

Both SoapFormatter and BinaryFormatter support serializing objects of types that inherit from other types. In other words, both do support inheritance.

You should probably ask another question about your specific problem with SoapFormatter. Also, just using different formatter most likely won't fix your problem (but you coul've tried it before asking here).

Upvotes: 3

Related Questions