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
12
votes
1 answer

Force protobuf-net to serialize all default values

I have a complex model serialized/deserialized with protobuf-net, and we had several bugs with this "feature" of not serializing default values. Example: [DataContract] class Foo{ public Foo(){ // Value forced by constructor this.Value =…
ghusse
  • 3,200
  • 2
  • 22
  • 30
12
votes
2 answers

Protobuf-net Error: Type is not expected, and no contract can be inferred: BlockHeader

Trying to get de-serialization of an openstreetmap pbf file working properly by following information from this thread as well as other sources: Protobuf-net Deserialize Open Street Maps I'm currently using the protobug dll from r480. I used…
ninehundreds
  • 1,097
  • 2
  • 21
  • 43
11
votes
3 answers

Alternative to protobuf-net - size and time efficient serializer to work with objects graph

Google protobuf is great protocol to serialize objects efficient, but it only supports serialization of trees, not graphs (lack of full Object Reference Tracking). There are few implementation of Google idea in .NET. (i.e. protobuf-csharp-port, or…
11
votes
1 answer

Google protobuf 3: deprecated a field, but cannot remove the dependencies?

I have a proto A that depends on proto B. Then I deprecated the field protoB: import "protoB.proto"; message ProtoA { string assignmentStatus = 1; protoB proto_b = 2 [deprecated = true]; } I'd think in this case I should be able to remove the…
HeyThere
  • 503
  • 1
  • 5
  • 19
11
votes
2 answers

Is protobuf-net thread safe?

I've noticed that when I use protobuf-net in a multi-threaded context it tends to fail intermittently with the following error: System.TimeoutException: Timeout while inspecting metadata; this may indicate a deadlock. This can often be avoided by…
jmcg
  • 357
  • 3
  • 12
11
votes
2 answers

Is it possible to use Protobuf-Net with a class without a parameterless constructor?

Using Protobuf-Net, I see that it does not seem possible to deserialize a class without having a parameterless constructor or I may be missing something? I don't want some of the classes with a parameterless constructor. Is there some kind of…
Stécy
  • 11,951
  • 16
  • 64
  • 89
11
votes
2 answers

"Invalid field in source data: 0" error with ProtoBuf-Net and Compact Framework

Is anyone aware of any issues when using ProtoBuf-Net to serialize/deserialize between compact framework and the full .Net framework? I have a class called LogData that I am serializing under compact framework 3.5, transmitting to a server (running…
10
votes
5 answers

Importing .proto files from another project

I have several contract projects that contains different protobuf files, but some of the message types have the same message type like message user { Address address = 1 } message Address { .... } I have now created a shared project and…
Joshlo
  • 734
  • 3
  • 9
  • 25
10
votes
2 answers

Generate C# from proto files and vice versa interpreting custom options

I'm using protobuf-net, and I'm trying to: Generate a C# class from a .proto file Generate a .proto file from a C# class That's pretty easy using respectively: protogen.exe tool Serializer.GetProto() method But the thing is that I need to…
Romain Verdier
  • 12,833
  • 7
  • 57
  • 77
10
votes
2 answers

How can I send multiple types of objects across Protobuf?

I'm implementing a client-server application, and am looking into various ways to serialize and transmit data. I began working with Xml Serializers, which worked rather well, but generate data slowly, and make large objects, especially when they…
dlras2
  • 8,416
  • 7
  • 51
  • 90
10
votes
1 answer

Confused about protobuf-net WCF usage

I have been following this tutorial to add protobuf-net to my WCF project. I have a shared DTO library. Both server and Client use those DTO classes. I have attributed all my Service methods with [OperationContract] attributes, but i have not…
user604613
10
votes
2 answers

Protobuf-Net Empty List

Came across protobuf-net, awesome! I have a question regarding serialization of empty lists. I start by declaring the object I want to serialize: [ProtoContract] class TestClass { [ProtoMember(1)] List _listOfInts = new List(); …
CanCan
  • 119
  • 6
10
votes
1 answer

C# .net protocol buffers - protobuf-net support for serializing dictionary of object values?

i'm new to protocol buffers and I am using protobuf-net for VS2010. from what i'm reading here Dictionary in protocol buffers, it doesn't seem that protobuf can serialize a dictionary with object types as values. but here on his site i read…
ijjo
  • 525
  • 9
  • 22
10
votes
3 answers

Protobuf-net serialization/deserialization

I checked but seem to be unable to see how to directly serialize a class to a byte array and subsequently deserialize from a byte array using Marc Gravell's protobuf-net implementation. Edit: I changed the question and provided code because the…
Matt
  • 7,004
  • 11
  • 71
  • 117
9
votes
1 answer

protobuf-net: Failing to deserialize ReadOnlyCollection

I'm trying to serialize and deserialize a ReadOnlyCollection using protobuf-net. However an exception is thrown upon deserialization when protobuf-net attempts to cast a List into a ReadOnlyCollection. var roc = new…
Mark
  • 510
  • 1
  • 5
  • 18