BinaryFormatter for serialization

前端 未结 2 1636
春和景丽
春和景丽 2021-01-25 01:05

I am working on my own remote desktop C# program. I wondered if I could Serialize using BinaryFormatter an object of my own for example \"Packet\" that contains properties of B

2条回答
  •  盖世英雄少女心
    2021-01-25 01:20

    BinaryFormatter is not a good choice for serialization over the network or to persistent storage, it is designed for serialization when you are communicating within the same machine. It is extremely intolerant of version differences of any assembly referenced in your serialized object on opposite ends of the connection, I personally have had a windows updates not being applied on one machine to cause the two sides to not be able to communicate.

    Instead use a serializer more designed for network communication like DataContractSerializer or a 3rd party binary serializer like ProtoBuf-net.

提交回复
热议问题