Conerlius / protobuf-net

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

AsReference = true and inheritance gives reflection exception: Object does not match target type. #242

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Simply try serialize :

var a = new A { B = new DerrivedFromBase { Count = 2, Name = "Derived" } };
    [ProtoContract]
        public class A
        {
            [ProtoMember(1, AsReference = true)]
            public Base B { get; set; }
        }

        [ProtoContract]
        [ProtoInclude(2, typeof(DerrivedFromBase))]
        public class Base
        {
            [ProtoMember(1)]
            public string Name { get; set; }
        }

        [ProtoContract]
        public class DerrivedFromBase : Base
        {
            [ProtoMember(3)]
            public int Count { get; set; }
        }

Original issue reported on code.google.com by bartosz....@gmail.com on 18 Oct 2011 at 10:21

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
http://stackoverflow.com/questions/7858697/protobuf-net-v2-r450-inheritance

Original comment by daveo...@gmail.com on 5 Nov 2011 at 7:10