protobuf-net

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 doesn't feel right. I'd like the .proto file to be considered to be the primary source-code...

Protocol Buffers In C#: How Are Boxed Value Types Handled

In the following examples: public class RowData { public object[] Values; } public class FieldData { public object Value; } I am curious as how either protobuf-net or dotnet-protobufs would handle such classes. I am more familiar with protobuf-net, so what I actually have is: [ProtoContract] public class RowData { [Prot...

Protocol buffer deserialization and a dynamically loaded DLL.

I am using protobuf-net for my protocol buffering. I have a dll I am loading dynamically. I can create an instance of a data class contained within the dll, and I can use and modify the created data object. However, When I attempt to serialize/deserialize the data object I get the following crash: {"Unable to identify known-type for Pro...

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 with a NullReferenceException. // Where "ms" is a memorystream containing the serialized /...

Serializing and deserializing unknown inherited types

I started looking at using proto-buf .Net for my serialization needs for media browser. In the new system we have a entity framework that can be extended with plug-ins. So, for example, we define a Media class in the core library, and then plug-ins can define subclasses such as Song. It seems that proto-buf .Net needs to know about...

protobuf and List<object> - how to serialize / deserialize?

I have a List<object> with different types of objects in it like integers, strings, and custom types. All custom types are protobuf-adjusted. What I wanna do now is to serialize / deserialize this list with protobuf.net. Up until now I suspect that I have to declare each and every type explicitly, which is unfortunately not possible with...

Obfuscation and protobuf.net - Exception: default enum value not defined

I'm being presented with the following Exception when trying to serialize a class that contains enums in an obfuscated project: ProtoBuf.ProtoException: The default enum value X is not defined for the optional property Y If I exclude all affected enums from obfuscation everything runs fine, however, I switched to protobuf.net to be...

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, ProtoInclude(50, typeof(BeginRequest))] abstract internal class BaseMessage { [ProtoMember(1)] abst...

XML vs Binary performance for Serialization/Deserialization

I'm working on a compact framework application and need to boost performance. The app currently works offline by serializing objects to XML and storing them in a database. Using a profiling tool I could see this was quite a big overhead, slowing the app. I thought if I switched to a binary serialization the performance would increase, bu...

Protobuf-net How to consume a WCF service in NET CF client?

Hello, I'm trying to consume a WCF webservice using the RPC capabilities of the Protobuf-net. Here's my service contract: namespace WcfEchoService { // NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config. [ServiceContract] public interface IEchoService ...

ProtoInclude adds unwanted dependencies

Hello, I just replaced .NET serialization with protocol buffers in a distributed cache application and the results are really impressive. The only thing I do not like is the fact that I need to add dependencies between a base message class and its children which creates a circular dependency. Is there an alternative to tagging base class...

Stubborn object won't serialize with protobuf-net

I'm integrating protobuf-net into our WCF services based solution but have ran into a snag that I can't figure out. The following class will serialize fine, all except for the ObjectId property. /// <summary> /// A service data object that represents a user of the system. /// </summary> [DataContract(Namespace = "http://LINKS.Service.S...

Passing IList<T> vs. IEnumerable<T> with protobuf-net

I noticed in the protobuf-net changelog that IList<> was supported but I'm getting the "Cannot create an instance of an interface" exception. If I change to IEnumerable<> then life is good. Does this sound correct? // Client call public override IList<IApplicationWorkflow> Execute(IRoleManagement service) { IList<A...

Protocol Buffers with Extensions.

I'm perhaps overlooking something, but I'm attempting to wrestle protocol buffers into an easy method for providing extensions later. That seems a bit unclear so I'll jump directly into the problem. I am writing an assembly to support various tasks, one of which includes describing structured data. Perfect time to use protocol buffers...

C# generic type in a base class

I'm writing a system that has a set of protocol buffers (using protobuf-net), I want to define something like this in an abstract class they all inherit off: public byte[] GetBytes() however, the protocol buffer serealiser requires a type argument, is there some efficient way to get the type of the inheriting class? Example: public ...

Protobuf attributes with a hierarchy of generic classes

I have a class hierarchy that looks like this. These classes contain a lot of other details which I have excluded. This is a simplification to focus on the serialization aspect of these classes. [ProtoInclude(1, typeof(Query<bool>))] [ProtoInclude(2, typeof(Query<string>))] [ProtoInclude(3, typeof(Query<int>))] [ProtoInclude(4, typeof...

How do I generate a .proto file from a C# class decorated with attributes?

Trying to get my mind around google protobuf. I found some implementation of protobuf in C# but they seems to lack one feature: the ability to generate .proto files automatically from an existing C# class decorated with attributes. The reason I want to do it this way instead of going from auto-generated C# classes from .proto file is be...

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 attributes that I could use or some other technique? ...

How to use list/array of some object inheritance with Protobuf/Protobuf-net ?

Using Protobuf/Protobuf-net and two classes, one base class and the other derived from the base. How would you serialize/deserialize a list ? For instance: public class SomeBase { ... } public class SomeDerived : SomeBase { ... } And the following field to be serialized: public List<SomeBase> SomeList; Keep in mind that t...

protobuf.net not serializing zero

Hello It looks like there is an encoding problem for 0 as Int64. Other values as Int64 ok. [ProtoMember(3)] private readonly Int64 _intValue is deserialized as Int64.MinValue Any idea? I confirm the bug. This class will not serialize properly if _val == 0 [ProtoContract] class VerySimple { [ProtoMember(1)] private readonl...