How to declare that a type is implementing an interface and a base class in ProtoBuf?

Viewed 305

We have one case in our model that looks like this:

[ProtoContract]
public interface ISomeInterface{
    //...
}

[ProtoContract]
[ProtoInclude(100,typeof(SomeImplementation)]
public class SomeRootClass {
    //...
}

[ProtoContract]
public class SomeImplementation: SomeRootClass,ISomeInterface{
    //...
}

At some point, we have an instance of SomeImplementation that is reference in a class:

[ProtoContract]
public class SomeClassWithInterfaceUsage{
    [ProtoMember(1)]
    public ISomeInterface SomeReference{get;set;}
}

When we try to serialize, we have this error:

System.InvalidOperationException : It was not possible to prepare a serializer for: SomeRootClass ----> System.InvalidOperationException : No serializer defined for type: ISomeInterface

So I changed the interface to look like:

[ProtoContract]
[ProtoInclude(100,typeof(SomeImplementation)]
public interface ISomeInterface{
    //...
}

But now I've this error:

System.InvalidOperationException : A type can only participate in one inheritance hierarchy

How should I manage this case?

1 Answers
Related