I'm unable to serialize my class using protobuf-net, the issue seems to be that protobuf-net is unable to serialize the interface.
interface MyInterface
{
string name;
}
[ProtoContract]
[ProtoInclude(1, typeof(MyClass1))]
[ProtoInclude(2, typeof(MyClass2))]
public abstract class ParentClass
{
[ProtoMember(1)]
List<MyInterface> elements;
}
[ProtoContract]
public class MyClass1 : ParentClass, MyInterface
{
[ProtoMember(1)]
int x;
}
[ProtoContract]
public class MyClass2 : MyInterface
{
[ProtoMember(1)]
string y;
}
I'm unable to serialize any object of type MyClass1, since the elements is a list of interface, which can be Mylass1 or MyClass2. I'm getting some encoding not set error.
Can anyone let me know how I can resolve this. Thanks.