Is it possible to serialize a struct , that implements an interface, using protobuf-net

Viewed 57

I am getting the error: 'Unexpected sub-type: StructId' when calling Serializer.Serialize(stream, Id); The entities are defined as follow :

[ProtoContract]
[ProtoInclude(101, typeof(ClassId))]
[ProtoInclude(102, typeof(StructId))]
public interface Id{}

[ProtoContract]
public class ClassId : Id {..}

[ProtoContract]
public struct 
StructId : Id {..}

I have also tried to call Serializer.PrepareSerializer<Id>(); , but it doesn't work either. Is it not supported or am I doing something wrong?

0 Answers
Related