I'm trying to implement a service contract that contains a method which takes a generic interface, and that generic interface itself is given an interface parameter. I've decorated the service interface with ServiceKnownType, I have decorated the service implementation with regular KnownType, and I have decorated the datacontract implementation with regular KnownType:
[ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(ICallbacks))]
[ServiceKnownType(typeof(Batch<object>))]
[ServiceKnownType(typeof(Command))]
public interface IActions
{
[OperationContract]
IResponse TakeAction(IBatch<ICommand> commands);
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Reentrant)]
[KnownType(typeof(Batch<object>))]
[KnownType(typeof(Command))]
internal class Actions : IActions
{
}
[DataContract]
[KnownType(typeof(Command))]
public class Batch<T> : IBatch<T>
{
}
For the record, I have Batch there because it seems that you can only express a knowntype for a generic type once--it appears to emit BatchOfanyType, but I'm not sure how to handle this.
The exception I'm getting is "Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer."
Is there anything obvious I'm doing wrong? Are generic interfaces of interfaces just not supported? For the record I'm on C# 2.0 and .NET 3.0 for this project.