protobuf-net

Using Protobuf-net, I suddenly got an exception about an unknown wire-type

心不动则不痛 提交于 2019-12-17 02:10:40
问题 (this is a re-post of a question that I saw in my RSS, but which was deleted by the OP. I've re-added it because I've seen this question asked several times in different places; wiki for "good form") Suddenly, I receive a ProtoException when deserializing and the message is: unknown wire-type 6 What is a wire-type? What are the different wire-type values and their description? I suspect a field is causing the problem, how to debug this? 回答1: First thing to check: IS THE INPUT DATA PROTOBUF

Overriding what's serialized on a per property basis

三世轮回 提交于 2019-12-14 02:29:29
问题 1) I'm using protobuf-net to sync two objects through network, as I'm able to track changes made between two sync I can only send what's changed instead of the whole object. So basically I'd like to override all nullable properties serialization based on a 'dirty' flag. Is there a "nice" way to do that? (I can live with a thread local bool that modify the behavior of my properties getter, but well..). 2) (bonus question) I went on and off of serializing the "real" object or a generic DTO

ProtoInclude adds unwanted dependencies

那年仲夏 提交于 2019-12-14 01:03:48
问题 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 with ProtoInclude? 回答1: In v1; [ProtoInclude] is the only way to support inheritance. In v2, you can use MetaType 's .AddSubType(...) method to achieve the same

Debug traces in Protobuf-net?

流过昼夜 提交于 2019-12-13 19:05:18
问题 I'm using Protobuf-net and from time to time have some problems, usually due to misunderstandings on my part. When these things happen, it would be very helpful if could turn on some kind of debug traces, so I can see what exactly is happening with my serialization requests. Does anyone know about something like this? 回答1: No; at least, not without bringing the project into scope (or at least: the pdb) and tracing through it manually in the debugger. 来源: https://stackoverflow.com/questions

IOException: Insufficient system resources when there is aplenty

两盒软妹~` 提交于 2019-12-13 18:42:37
问题 I am coming across an error when I am trying to write out a file (~50 MB) I will randomly get the following error: IOException: Insufficient system resources exist to complete the requested service I currently have 200+ GB free on the hard drive and about 20 GB free in memory. I am using protobuf to serialize the data out to disk. There are around four threads running similar operations at the same time on different files. There should not be anything else trying to access the file as it was

ProtoBuf-Net Performance

ぐ巨炮叔叔 提交于 2019-12-13 17:24:15
问题 In the example below: Would Class1 serialization take almost twice as long as Class2 serialization? Or would protobuf-net handle the byte[] in Class1 as already serialized data? Pseudo example: [ProtoContract] class Class1 { [ProtoMember(1)] public byte[] SerializedData { get; set; } } [ProtoContract] class Class2 { [ProtoMember(1)] public Class3 NonSerializedData { get; set; } } [ProtoContract] class Class3 { [ProtoMember(1)] public string Address{ get; set; } [ProtoMember(2)] public string

protobuf-net concurrent performance issue in TakeLock

旧巷老猫 提交于 2019-12-13 16:57:30
问题 We're using protobuf-net for sending log messages between services. When profiling stress testing, under high concurrency, we see very high CPU usage and that TakeLock in RuntimeTypeModel is the culprit. The hot call stack looks something like: *Our code...* ProtoBuf.Serializer.SerializeWithLengthPrefix(class System.IO.Stream,!!0,valuetype ProtoBuf.PrefixStyle) ProtoBuf.Serializer.SerializeWithLengthPrefix(class System.IO.Stream,!!0,valuetype ProtoBuf.PrefixStyle,int32) ProtoBuf.Meta

Protobuf.net “The type cannot be changed once a serializer has been generated”

亡梦爱人 提交于 2019-12-13 16:25:50
问题 I have some fairly simple code using Protobuf.net, which is throwing a very odd exception. In MetaType.cs on line 167 it throws a InvalidOperationException "The type cannot be changed once a serializer has been generated". What does this mean and how do I fix it? My code looks like this: This method starts off all the serialising: while (!Parallel.For(0, 100, (i) => { Widget w; lock (f) { w = f.CreateWidget(); } SerialiseWidget(w); }).IsCompleted) { Thread.Sleep(10); } Pretty simple, it just

protobuf-net deserialization System.IO.EndOfStreamException under mono

依然范特西╮ 提交于 2019-12-13 04:38:10
问题 I have been using protobuf-net to send some objects over the wire and everything has been working nicely until now. However, I have come across a particular instantiation of my class that fails to deserialize when running under mono. The exact same object deserializes correctly running under .net. I have verified that it is the exact same byte[] that I receive over the wire when I run under mono and under .net by checking the md5 sum. This would indicate that the problem must be with protobuf

Send binary file from Java Server to C# Unity3d Client with Protocol Buffer

眉间皱痕 提交于 2019-12-13 03:44:29
问题 I have asked this question https://stackoverflow.com/questions/32735189/sending-files-from-java-server-to-unity3d-c-sharp-client but I saw that it isn't an optimal solution to send files between Java and C# via built-in operations, because I also need also other messages, not only the file content. Therefore, I tried using Protobuf, because it is fast and can serialize/deserialize objects platform independent. My .proto file is the following: message File{ optional int32 fileSize = 1;