More specifically, the question is:
How to serialize a class with WCF that has (must have) interface types in property signatures because it implements an interface?
This is a design question. I’m not looking for a hack.
The purpose is to keep the interface definitions separate from implementing classes and hence not let interfaces refer to implementing classes.
I know that we’re not supposed to pass around interfaces with WCF and
also that there are still (non-interoperable) ways to do it (like using NetDataContractSerializer or the ServiceKnownType attribute), but that leaves me with the question: is there a proper way to use classes based on interfaces with WCF or should this not be attempted at all?
I found a solution to my own specific problem.
The problem was that I was marking the properties (of an interface type) as DataMember. By instead marking corresponding private members as DataMember (and make sure that their types are concrete classes) the problem is solved.
Example: