I can't make this scenario work. Here's the pattern-
[DataContract]
/*abstract*/ class BaseT
{ ... }
[DataContract]
class ChildT : BaseT
{ ... }
[DataContract]
class MessageContents
{
[DataMember]
public BaseT[] XX; // Array of BaseT objects. I need WCF to somehow figure out that they're actually ChildT.
}
// ...receive a webHttp request of type MessageContents...
// cast to use MessageContents.XX as a ChildT[] instead of a BaseT[]
ConcreteClass[] QQ = (ConcreteClass[])request.xx;
I've tried annotating practically everything with KnownType or KnownServiceType to no avail.
If I make BaseT abstract, I get a deserialization error 'cannot instance abstract class'. If I make BaseT concrete, I don't get a deserialization error. Instead, when I go to cast it to ChildT, I'm getting "unable to cast object of type 'BaseT[]' to type 'ChildT[]'".