patrick31415 / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
Other
0 stars 0 forks source link

Exception deserializing DynamicType that is byte[] #285

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Please include an e-mail address if this might need a dialogue!
==============

What steps will reproduce the problem?
    public class Program
    {
        public static void Main(string[] args)
        {
            MyArgs test = new MyArgs
            {
                Value = new byte[] { 0x1 }
            };

            byte[] buffer = new byte[256];
            using (MemoryStream ms = new MemoryStream(buffer))
            {
                Serializer.Serialize(ms, test);
            }

            using (MemoryStream ms = new MemoryStream(buffer))
            {
                MyArgs outArgs = Serializer.Deserialize<MyArgs>(ms);
                Console.WriteLine(outArgs.Value);
            }
        }
    }

    [ProtoContract]
    public class MyArgs
    {
        [ProtoMember(1, DynamicType = true)]
        public object Value;
    }

What is the expected output? What do you see instead?
Unhandled Exception: ProtoBuf.ProtoException: Unable to create type 
System.Byte[]: Value was invalid. ---> System.Argume
ntException: Value was invalid.

What version of the product are you using? On what operating system?
r488 Windows 7

Please provide any additional information below.

Original issue reported on code.google.com by jay.tha...@gmail.com on 29 Mar 2012 at 9:11