Questions tagged [protobuf-net]

An independent implementation of Google's protobuf binary serialization format, protobuf-net approaches the problem-space with common .NET coding styles, but retaining the high performance, dense output and cross-platform interoperability.

An independent implementation of Google's protobuf binary serialization format, protobuf-net approaches the problem-space with common .NET coding styles, but retaining the high performance, dense output and cross-platform interoperability. It's compatible with most of the .NET family, including .NET 2.0/3.0/3.5, .NET CF 2.0/3.5, Mono 2.x, Silverlight 2, etc.

In particular (compared to most implementations), it allows:

  • both code-first and contract-first development
  • mutable objects
  • inheritance

Oh, and it is pretty darned fast too.

Resources

1771 questions
23
votes
3 answers

Deserialize unknown type with protobuf-net

I have 2 networked apps that should send serialized protobuf-net messages to each other. I can serialize the objects and send them, however, I cannot figure out how to deserialize the received bytes. I tried to deserialize with this and it failed…
Nick VanderPyle
  • 2,939
  • 3
  • 26
  • 33
23
votes
5 answers

Dynamic Object Serialization

I tried to serialize a DynamicObject class with BinaryFormatter, but: Output file is too big, not exactly wire-friendly Circular References not handled (stuck while serializing) Since serializing a DynamicObject means very little by itself, here's…
raine
  • 817
  • 1
  • 15
  • 26
23
votes
3 answers

Protobuf-net serialization without annotation

I looked at this answer and I am in a situation where I don't need to maintain backward compatibility and I have to have a solution that works without having to decorate dozens of classes with the attributes needed for protobuf-net. So I tried using…
codelove
  • 1,396
  • 3
  • 17
  • 35
20
votes
1 answer

What does the ProtoInclude attribute mean (in protobuf-net)

In the ProtoBuf-Net implementation, what does the ProtoInclude attribute mean, and what does it do? An example would be appreciated. I saw it in this post and I'm not sure what it does. The example was: [Serializable, ProtoContract, …
Mike Dinescu
  • 54,171
  • 16
  • 118
  • 151
20
votes
4 answers

Protocol buffers detect type from raw message

Is it possible to detect the type of a raw protocol buffer message (in byte[]) I have a situation where an endpoint can receive different messages and I need to be able to detect the type before I can deserialize it. I am using protobuf-net
Yavor Shahpasov
  • 1,453
  • 1
  • 12
  • 19
20
votes
3 answers

protobuf-net Serialize To String and Store in Database Then De Serialize

I'd like to serialize/de-serialize an object using a string. Just to note, when I serialize/de-serialize to a file everything works fine. What I'm trying to do is get a string so I can store it in the database and then pull it out later to…
Robert
  • 568
  • 1
  • 6
  • 21
19
votes
7 answers

protobuf-net does not deserialize DateTime.Kind correctly

using protobuf-net.dll Version 1.0.0.280 When I deserialize a DateTime (wrapped in an object), the date/time is ok but the DateTime.Kind property is 'Unspecified' Consider this test case to serialize/deserialize a DateTime. [TestMethod] public void…
wal
  • 17,409
  • 8
  • 74
  • 109
19
votes
1 answer

How to model HashMap/Dictionary in the ProtoBuf efficiently

I have a protobuf file serialized by .NET code and I would like to consume it into Java. In the .NET code, there is Dictionary data type and the proto schema looks like message Pair { optional string key = 1; optional string value =…
Lan
  • 6,470
  • 3
  • 26
  • 37
18
votes
1 answer

protobuf-net serializing object graph

If I have object A and B both contain some field serialized field F, and both point to the same serializable object C. Does protobuf-net serialize by reference or serialize by value? When the object graph is deserialized, does protobuf-net generate…
jz87
  • 9,199
  • 10
  • 37
  • 42
17
votes
6 answers

Protocol buffers in C# projects using protobuf-net - best practices for code generation

I'm trying to use protobuf in a C# project, using protobuf-net, and am wondering what is the best way to organise this into a Visual Studio project structure. When manually using the protogen tool to generate code into C#, life seems easy but it…
Ray Hayes
  • 14,896
  • 8
  • 53
  • 78
17
votes
2 answers

protobuf-net enum serialization

What needs to be done in order to serialize enums with protobuf-net? I'm getting the below error when serializing a class having an enum property, if the DataMember attribute is removed from the property declaration it works…
Kimi
  • 13,621
  • 9
  • 55
  • 84
17
votes
1 answer

protobuf-net serialization without attributes

I have an assembly with DataContracts and I need to generate .proto schema for it to be able to exchange the data with java system. The DataContracts code can be changed but I cannot add [ProtoContract] and [ProtoMember] attributes in it because it…
Mike
  • 2,468
  • 3
  • 25
  • 36
16
votes
4 answers

Options for RPC in Mono? (WCF Alternatives)

I have had the opportunity to spend a great number of hours trying to use WCF in mono. It is simply too poorly implemented at this point to be put into a production environment, for anything beyond toy applications. It does not survive a 24/7…
John Hargrove
  • 701
  • 6
  • 23
15
votes
2 answers

Serializing with ProtoBuf.NET without tagging members

I've read somewhere a comment by the author of ProtoBuf.NET that: There are options to automatically infer the numbers, but that is brittle and not recommended. Only use this if you know you never need to add more members (it orders them…
damageboy
  • 2,097
  • 19
  • 34
15
votes
1 answer

How to store a byte array to StackExchange.Redis?

I want to use the MessagePack, ZeroFormatter or protobuf-net to serialize/deserialize a generic list and store it in Redis using the stackexchange.redis client. Now I'm storing a JSON string with the StringSetAsync() method. But I can't find any…
tedi
  • 6,350
  • 5
  • 52
  • 67