protobuf-net

how do I enable string interning in protobuf-net?

偶尔善良 提交于 2019-12-19 08:40:34
问题 I am using v2 rev 421. When I saved the stream produced by protobuf-net and put it through the strings utility, it discovered many duplicate strings. I am talking about the strings produced by the application, which can be interned, but the string interning does not seem to be on by default. How do I enabled it? Thanks. 回答1: There are two separate types of interning here; there's interning while deserializing - this is always enabled, so if duplicates are in the data , you should only see a

Error while using ProtoBuf-Net with flags enum

核能气质少年 提交于 2019-12-19 07:35:54
问题 While using ProtoBuf-Net and serializing an enum property, where the enum is set to [FlagsAttribute], I received the following error message when serializing an enum value composed of multiple flags. The error is: The value (MyEnum.MyValue) has no wire-representation for property MyProperty Where MyEnum is: [Flags] public Enum MyEnum { MyValue = 0, MyValue1 = 1, MyValue2 = 2, MyValue4 = 4, MyValue8 = 8, } and MyProperty = MyEnum.MyValue2 | MyEnum.MyValue4; Seems to be a bug in protobuf-net?

Error while using ProtoBuf-Net with flags enum

喜你入骨 提交于 2019-12-19 07:35:22
问题 While using ProtoBuf-Net and serializing an enum property, where the enum is set to [FlagsAttribute], I received the following error message when serializing an enum value composed of multiple flags. The error is: The value (MyEnum.MyValue) has no wire-representation for property MyProperty Where MyEnum is: [Flags] public Enum MyEnum { MyValue = 0, MyValue1 = 1, MyValue2 = 2, MyValue4 = 4, MyValue8 = 8, } and MyProperty = MyEnum.MyValue2 | MyEnum.MyValue4; Seems to be a bug in protobuf-net?

Memory usage serializing chunked byte arrays with Protobuf-net

旧巷老猫 提交于 2019-12-19 06:06:07
问题 In our application we have some data structures which amongst other things contain a chunked list of bytes (currently exposed as a List<byte[]> ). We chunk bytes up because if we allow the byte arrays to be put on the large object heap then over time we suffer from memory fragmentation. We've also started using Protobuf-net to serialize these structures, using our own generated serialization DLL. However we've noticed that Protobuf-net is creating very large in-memory buffers while

Why I have to use [ProtoInclude]?

烂漫一生 提交于 2019-12-18 17:02:05
问题 I have read many questions about inheritance feature in protobuf-net. I just wonder that if I can use [DataContract],[DataMember] in the same way of using [ProtoContract],[ProtoMember]. Why I could not use [KnowType] instead of using [ProtoInclude]? I raise this question because I used [DataContract],[DataMember] for protobuf-net's serialization already. There was no need to add "Protobuf-net". It used only "System.Runtime.Serialization". But... Now if my class need to inherit from some class

How can I send multiple types of objects across Protobuf?

喜你入骨 提交于 2019-12-18 12:30:23
问题 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 need to be sent over the net. So I started looking into Protobuf, and protobuf-net. My problem lies in the fact that protobuf doesn't sent type information with it. With Xml Serializers, I was able to build a wrapper which would send and receive any

How can I send multiple types of objects across Protobuf?

寵の児 提交于 2019-12-18 12:30:22
问题 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 need to be sent over the net. So I started looking into Protobuf, and protobuf-net. My problem lies in the fact that protobuf doesn't sent type information with it. With Xml Serializers, I was able to build a wrapper which would send and receive any

Protobuf attributes with a hierarchy of generic classes

大憨熊 提交于 2019-12-18 09:08:08
问题 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(Query<decimal>))] [ProtoInclude(5, typeof(Query<DataSet>))] abstract class Query { public string Result { get; set; } } [ProtoInclude(1, typeof(SpecialQuery)]

ProtoBuf-net serializing IEnumerable<T>

两盒软妹~` 提交于 2019-12-18 07:50:05
问题 I'm trying to use ProtoBuf-NET in my project (it's mostly Silverlight 4 project). I'm having difficulties serializing my Model collections, they all are defined like this: private List<T> _itemsSet; public IEnumerable<T> TSet { get {return _itemsSet;} set {_itemsSet = value == null ? new List<T>() : new List<T>(value);} } public void AddT(T item) { //Do my logic here _itemsSet.Add(item); } Update: First I can't serialize it - No serializer defined for type: System.Collections.Generic

Protobuf-net fails to serialize property with only getter - Cannot apply changes to property

流过昼夜 提交于 2019-12-18 06:38:32
问题 I am using protobuf-net to serialize an object and I get exception: Cannot apply changes to property TestProject.TestMessage.ClientId with stacktrace: at ProtoBuf.Serializers.PropertyDecorator.SanityCheck(TypeModel model, PropertyInfo property, IProtoSerializer tail, Boolean& writeValue, Boolean nonPublic, Boolean allowInternal) at ProtoBuf.Serializers.PropertyDecorator..ctor(TypeModel model, Type forType, PropertyInfo property, IProtoSerializer tail) at ProtoBuf.Meta.ValueMember