Reputation: 20697
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?
Upvotes: 2
Views: 414
Reputation: 1357
As far as I know this is not supported, check Marks answer here: enter link description here
I did end up declaring only the type and using objects for the properties with the DynamicType flag on the ProtoMemberAttribute
Upvotes: 2