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
15
votes
2 answers

Protobuf-net deserializes empty collection to null when the collection is a property of another type

I've run in to a problem with protobuf-net and I hope it is user error and not a bug with protobuf-net. I can serialize an empty collection (for example, IDictionary()) and then deserialize the collection. The deserialization results…
Ryan Rodemoyer
  • 5,548
  • 12
  • 44
  • 54
14
votes
2 answers

What does "1", "2", "3" mean in protobuf?

package tutorial; message Person { required string name = 1; required int32 id = 2; optional string email = 3; } What does "1", "2", "3" mean ?
why
  • 23,923
  • 29
  • 97
  • 142
14
votes
4 answers

protobuf-net inheritance

Marc mentioned on stackoverflow that it will be possible in v2 of protobuf-net to use ProtoInclude attribute (or similar approach) to serialize/deserialize class hierarchy without a need to specify each subtype in the base class. Is this implemented…
Egor Pavlikhin
  • 17,503
  • 16
  • 61
  • 99
14
votes
1 answer

Is it best to have many field in protobuf message or nested messages?

I tried to find some recommendations on the web but could not find anything relevant. Let's say that I am creating a protocol buffer message that will contain a lot of fields (50+). Is it best to keep all the fields at the same level or to organize…
14
votes
2 answers

Are there any Tutorials for Protobuf-net?

I have been reading about protobuf-net and it is amazing! Are there any tutorials that I could use? (More specifically for Dictionary and contracts for generics) Are there any tips associated with it? Could I simply plug it into my…
akshaykarthik
  • 1,055
  • 2
  • 13
  • 30
14
votes
1 answer

Protobuf-Net error message: No Serializer defined for type: System.Type

I am getting the following error message when trying to serialize List>: No Serializer defined for type: System.Type I tried both, just serializing the above collection or serializing a class that has the same collection…
Matt
  • 7,004
  • 11
  • 71
  • 117
13
votes
2 answers

How to use protobuf-net with immutable value types?

Suppose I have an immutable value type like this: [Serializable] [DataContract] public struct MyValueType : ISerializable { private readonly int _x; private readonly int _z; public MyValueType(int x, int z) : this() { _x = x; _z =…
theburningmonk
  • 15,701
  • 14
  • 61
  • 104
13
votes
2 answers

Using a custom WCF serializer in Silverlight

In "full" .NET it is pretty easy to swap out the serializer - either in configuration, or via custom attributes. However, I want to do something similar in Silverlight's WCF - i.e. provide a different serialization engine. I will provide the engine…
Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
12
votes
1 answer

What is protobuf-net SerializeWithLengthPrefix tag argument for?

This method accepts as the last argument an integer, but I'm not sure I understand what I would use it for exactly. Serializer.SerializeWithLengthPrefix(stream, object, PrefixStyle.Base128, [tag]); The same holds true for the corresponding…
Simone
  • 3,607
  • 1
  • 31
  • 37
12
votes
3 answers

How to serialize/deserialize large list of items with protobuf-net

I have a list of about 500 million items. I am able to serialize this into a file with protobuf-net file if I serialize individual items, not a list -- I cannot collect the items into List of Price and then serialize because I run out of memory. So,…
user1044169
  • 2,686
  • 6
  • 35
  • 64
12
votes
2 answers

Serialize List (where the objects are supported primitives) in Protobuf.NET?
How to I serialize an object like this with protobuf-net: public class MyObject{ public string Key {get; set;} public List Values {get; set;} } When I try to serialize this with a TypeModel protobuf-net throws an error stating that it…
Timothy Baldridge
  • 10,455
  • 1
  • 44
  • 80
12
votes
2 answers

How to compare two .NET object graphs for differences?

In our Client/Server Application we've been using BinaryFormatter for the serialization process. For performance reasons we are trying to migrate to protobuf-net ( http://code.google.com/p/protobuf-net/ ). Our software transmits huge graphs with…
TwinHabit
  • 753
  • 8
  • 22
12
votes
3 answers

Google.Protobuf.InvalidProtocolBufferException: Protocol message contained an invalid tag (zero)

I have a problem with my school project, i use Protobuf library but i have the following error: Google.Protobuf.InvalidProtocolBufferException" Protocol message contained an invalid tag (zero). My protocol message wrapper is: syntax =…
Jean Walrave
  • 191
  • 1
  • 2
  • 13
12
votes
2 answers

protobuf.net Unexpected subtype

I'm encountering this Exception in my project using Protobuf.net: InvalidOperationException "Unexpected sub-type: foo" I have a class which I'm sending which looks like this: class message { list listOfBars; } foo inherits off bar,…
Martin
  • 12,469
  • 13
  • 64
  • 128
12
votes
2 answers

Decoding protobuf without schema

Is it possible to decode protobuf serialized files without schema with tools or anything that would decode the binary data to readable format?
andre_lamothe
  • 2,171
  • 2
  • 41
  • 74