Deserialization problem with protobuf-net

804 views
Skip to first unread message

Antonio Ramos

unread,
Sep 12, 2014, 5:44:11 AM9/12/14
to prot...@googlegroups.com
Hi all, this is my first time with protobuf protocol and protobuf-net.

I have the following question. I read in a buffer of bytes one response wich contains two proto messages. I´m trying deserializate those messages.

I can deserializate the first one perfectly. But when i try to deserializate de second one i have a deserialization wired exception: "Invalid wire-type; this usually means you have over-written a file without truncating or setting the length; see http://stackoverflow.com/q/2152978/23354"

My code is de following:

            int valo = networkStream.Read(buffer, 0, buffer.Length);
           
            using (MemoryStream streamR = new MemoryStream(buffer))
            {
                try
                {           
                    Command comando = Serializer.DeserializeWithLengthPrefix<Command>(streamR, PrefixStyle.Base128); 
                    ChannelInfo chInfo = Serializer.DeserializeWithLengthPrefix<ChannelInfo>(streamR, PrefixStyle.Base128);                
                }
                catch (Exception ex)
                {
                }
            }

What can i do???

thanks!!

Marc Gravell

unread,
Sep 12, 2014, 3:23:24 PM9/12/14
to Antonio Ramos, Protocol Buffers
Also; don't swallow exceptions. In fact, if you can't do anything useful, don't even try/catch - just let it explode.

Marc

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.



--
Regards,

Marc

Antonio Ramos

unread,
Sep 12, 2014, 3:40:16 PM9/12/14
to Marc Gravell, Protocol Buffers

Ok, next Monday I'll see everything that you told me.

I have an emulator (made in java) which work perfectly. I am trying to make the same in c#. I use wireshark for to read the socket transmision and compare it the diference between mine and java software.

Thanks!!

Reply all
Reply to author
Forward
0 new messages