serialize in .NET, deserialize in C++

前端 未结 7 954
死守一世寂寞
死守一世寂寞 2021-02-13 20:03

I have a .NET application which serializes an object in binary format. this object is a struct consisting of a few fields.

I must deserialize and use this object in a C+

7条回答
  •  伪装坚强ぢ
    2021-02-13 20:27

    If you are using BinaryFormatter, then it will be virtually impossible. Don't go there...

    Protocol buffers is designed to be portable, cross platform and version-tolerant (so it won't explode when you add new fields etc). Google provide the C++ version, and there are several C# versions freely available (including my own) - see here for the full list.

    Small, fast, easy.

    Note that the v1 of protobuf-net won't handle structs directly (you'll need a DTO class), but v2 (very soon) does have tested struct support.

提交回复
热议问题