protobuf-net

Protobuf-net won't deserialize data from Protobuf.js

随声附和 提交于 2019-12-24 16:33:24
问题 I'm using Protobuf for the communication between my web client and server (C#), using WebSocket. On the client, the de/serialization is done through Protobuf.js and, on the server, using protobuf-net. The problem is that, when using aggregation with abstract classes, protobuf-net can't deserialize the data sent by Protobuf.js. This is the stack trace: ProtoException: No parameterless constructor found for Base. at ProtoBuf.Meta.TypeModel.ThrowCannotCreateInstance(Type type) na c:\Dev\protobuf

How do I change my previously saved List type to serialize into an Array type

只愿长相守 提交于 2019-12-24 12:41:47
问题 Previously, we serialized a property as a List<byte> Now we want to change it to be a byte[] . It was out understanding that you should be able to swap out collection types freely between version but we get a ProtoBuf.ProtoException [TestFixture, Category("Framework")] class CollectionTypeChange { [Test] public void TestRoundTrip() { var bytes = new List<byte>() {1,2,4}; var a = new ArrayHolder(bytes); var aCopy = Deserialize<ArrayHolder>(Serialize(a)); //Passes Assert.That(aCopy

How POCO (de)serialization works in protobuf-net?

做~自己de王妃 提交于 2019-12-24 11:51:15
问题 Is it possible to (de)serialize a POCO type using neither protobuf-net attributes nor explicitly adding types into the model? 回答1: At the moment - in short, no. It needs to have a basic understanding of how you intend it to operate. I guess maybe I could add something to let you specify a default strategy for completely unadorned types (things that aren't DataContract , ProtoContract or XmlType ), but the most appropriate option there would be "all public members" (much like XmlSerializer ).

issue while serializing graphs with protobuf.net

*爱你&永不变心* 提交于 2019-12-24 09:37:13
问题 while playing with the newly released protobuf.net, we are encountering the issue illustrated in the code below: [ProtoContract] class Node { public Node() { ChildLinks = new List<Link>(); ParentLinks = new List<Link>(); } [ProtoMember(1, IsRequired = true)] public string Data { get; set; } [ProtoMember(2, IsRequired = true)] public List<Link> ChildLinks { get; set; } [ProtoMember(3, IsRequired = true)] public List<Link> ParentLinks { get; set; } public void AddChild(Node child) { Link link =

Protocol Buffers c# (protobuf-net) Message::ByteSize

谁都会走 提交于 2019-12-24 08:58:26
问题 I am looking for the protobuf-net equivalent to the C++ API Message::ByteSize to find out the serialized message length in bytes. 回答1: I haven't played with the C++ API, so you'll have to give me a bit more context / information. What does this method do? Perhaps a sample usage? If you are consuming data from a stream, there are "WithLengthPrefix" versions to automate limiting to discreet messages, or I believe the method to just read the next length from the stream is on the public API. If

Inheritance in protobuf.net, adding a lower base class still backward compatible?

天大地大妈咪最大 提交于 2019-12-24 08:26:28
问题 I have been using protobuf.net for a while and it is excellent. I can have a class which is inherited from a base class, I can serialise the derived class by using ProtoInclude statements in the base class. If my base class originally had only say two ProtoInclude statements when the object was serialised, say [ProtoInclude(100, typeof(Vol_SurfaceObject))] [ProtoInclude(200, typeof(CurveObject))] internal abstract class MarketDataObject I can still deserialise that same object in to code that

Getting 'A reference-tracked object changed reference during deserialization' exception

纵然是瞬间 提交于 2019-12-24 07:45:46
问题 This question is related to this one: https://stackoverflow.com/questions/7906356/how-to-solve-a-a-reference-tracked-object-changed-reference-during-deserializat Since the above post has been closed, I created a new one that includes the test code to reproduce the problem and the exception stack trace. What is going here, why the error? Also I am not clear on the tag for the ProtoInclude. If the tag is equal to a ProtoMember then I get an exception about a duplicate field number. So, I

Can i use protobuf-net as a SAX-like parser without a full type definition?

大憨熊 提交于 2019-12-24 07:07:13
问题 It was mentioned here that protobuf-net can be used like a SAX parser, but I couldn't find examples for this that did not require a more or less complete description of the object to parse. (Skip to point 2) for the question, 1) just provides some context) 1) Perhaps I should provide some context first: I am currently using JSON.Net in my project and have created several JSONConverters to customize how various types are serialized – basically all major types have hand-written serialization

interleave protobuf-net and file

北慕城南 提交于 2019-12-24 06:44:23
问题 I need to exchange both protobuf-net objects and files between computers and am trying to figure out the best way to do that. Is there a way for A to inform B that the object that follows is a protobuf or a file? Alternately, when a file is transmitted, is there a way to know that the file has ended and the Byte[] that follows is a protobuf? Using C# 4.0, Visual Studio 2010 Thanks, Manish 回答1: This has nothing to do with protobuf or files, and everything to do with your comms protocol,

MSMQ and ProtoBuf-Net serialization c#

安稳与你 提交于 2019-12-24 05:53:05
问题 I have a class with many properties, one of them are byte[] property. I would like to send this class to another server using MSMQ. But before sending it I would like to serialize it using ProtoBuf-Net. Is it possible to attach ProtoBuf-Net serializer to MSMQ? Frankly speaking I do not understand how to send class to queue. I have tried to use code below to put class to MSMQ queue but got exception "There was an error generating the XML document." EntityBase is a class which I would like to