protobuf-net

protobuf-net deserialization without providing out type

旧城冷巷雨未停 提交于 2019-12-08 08:15:05
问题 Why is not possible to Deserialize without providing output type? Typically if two endpoints are communicating, both ends are sharing the same types. In my case i'm using exactly the same library on the client and on the server application. On startup i register all my types both on client and server like this: var metaType = RuntimeTypeModel.Default.Add( type, false ); foreach( var prop in type.GetProperties() ) metaType.Add( i++, prop.Name ); and so i expect protobuf to try to understand

Issue deserializing (protocolBuffer) serialized data using protobuf-net

空扰寡人 提交于 2019-12-08 07:44:10
问题 I serialized data using protobuf-net, and am able to deser the same in C#. putting a C# dummy w# var file = File.Create("animal.bin"); //Creating Msg - Fill the Data animal.id = "1"; animal.Name = "Rat"; animal.host = "Cheetha"; ProtoBuf.Serializer.SerializeWithLengthPrefix(file, animal, PrefixStyle.Base128, 1); animal.id = "2"; animal.Name = "Cat"; animal.host = "Cheetha"; ProtoBuf.Serializer.SerializeWithLengthPrefix(file, animal, PrefixStyle.Base128, 1); .... animal.id = "4"; animal.name =

Protobuf-net: Using Hidden Members does not work

我与影子孤独终老i 提交于 2019-12-08 06:45:47
问题 Using types with hidden fields leads to an "Unable to determine member" Exception (V2 via RuntimeTypeModel without any attributes). Removing the Length check in this line in MetaType.cs solves the problem for this special use case. if(members != null && members.Length == 1) mi = members[0]; But I fear there is a reason for the length check, so simply removing it might not be an adequate solution. Using members[0] works in this case, because the hidden base class members go at the end of the

Update existing field in List<T> and re-save into same protobuf.net file

北城以北 提交于 2019-12-08 06:45:46
问题 Got POCO with 100+ fields (using DataMember(Order=X) attribute to mark them for ProtoBuf.Net serialisation). We need to do some post processing of the file where one field's value needs to calced (which we can only do once we have read through it once) be updated and saved down again. Atm we are resaving into new file and this obviously has some IO/file overhead. Is there any way I can update existing file where only Field "X"'s value needs to be updated and saved down. Hopefully this should

Protocol buffer deserialization and a dynamically loaded DLL in Compact Framework

末鹿安然 提交于 2019-12-08 06:09:11
问题 I saw a question related to this on the full framework here. Since it seems to have stayed unresolved for quite a while and this is for the compact framework, I though it would be better to create a new question for it. I want to deserialize types for which I am loading assemblies dynamically (with Assembly.LoadFrom) and I am getting a "Unable to identify known-type for ProtoIncludeAttribute" error. In the related question I mentioned, it was hinted that hooking AppDomain.AssemblyResolve

Partial and asynchronous deserialization c# with protobuf-net

喜夏-厌秋 提交于 2019-12-08 05:36:18
问题 Context I'm have a file with the following structure: [ProtoContract] public class Data { [ProtoMember(1)] public string Header { get; set; } [ProtoMember(2)] public byte[] Body { get; set; } } The code that reads / writes the data to a file is running on a asp.net mvc webapi context. I'm trying to keep every blocking IO async to minimize blocking and achieve the best scalability. Reading and writing from files does support ReadAsync, WriteAsync and CopyToAsync. The body can be reasonably

protobuf-net Inheritance & Field Numbers

末鹿安然 提交于 2019-12-08 03:18:45
问题 I am trying to construct a serialisation system for our application that must be able to handle inheritance. To further complicate matters the application is extensible so types might are very unlikely to be known at compile time. I have read through a previous stackoverflow question that was answered and that helped me get a long way to my goal but I have hit a stumbling block that is probably more of a lack of understanding than any real issue! So this is the code that I have currently...

Serializing and Sending a Protocol Buffers Message

元气小坏坏 提交于 2019-12-08 02:27:29
问题 I have written this protobuf message in c# C# client: public AddressBook InitializeAdressBook() { Person newContact = new Person(); AddressBook addressBookBuilder = new AddressBook(); Person john = new Person(); john.id=1234; john.name="John Doe"; john.email="jdoe@example.com"; Person.PhoneNumber nr = new Person.PhoneNumber(); nr.number="5554321"; john.phone.Add(nr); addressBookBuilder.person.Add(john); TextBox.Text += ("Client: Initialisiert? " + addressBookBuilder.ToString()) + "\t" + "\n";

Is it possible to serialize a list of System.Object objects using protocol buffers

青春壹個敷衍的年華 提交于 2019-12-08 01:59:47
问题 I have a list of objects of various data types (DateTime, int, decimal, string). List<object> myObjects = new List<object>(); myObjects.Add(3); myObjects.Add(3.9m); myObjects.Add(DateTime.Now); myObjects.Add("HELLO"); I was able to serialize this list using protobuf-net, but deserialization always throws the exception: "Additional information: Type is not expected, and no contract can be inferred: System.Object". using (var ms = new MemoryStream()) { Serializer.Serialize(ms, list2); var bytes

Protocol buffer deserialization and a dynamically loaded DLL

落爺英雄遲暮 提交于 2019-12-08 00:57:21
问题 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 ProtoIncludeAttribute: MyDataDLL.MyDataClass, MyDataDLL, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"} and sometimes a crash saying that MyDataClass is