I am trying to define a WCF contract that returns an interface, something like below:
[ServiceContract]
public interface IMyContracts
{
[OperationContract]
IMyInterface GetData(string request);
}
To get this to work I think my interface (IMyInterface
) would have to implement ISerializable
to ensure classes implementing my interface can be serialized. This then means I have to manually implement serialization for any classes implementing my interface.
It seems that either I use my interface and risk runtime errors if a class is used that is not serializable, or I make the interface implement ISerializable
and have the associated hassle of manual implementation.
Am I confusing myself and missing something obvious? How have other people returned interfaces using WCF and avoided this problem?
Thanks very much.