So as to enable aysc callbacks to the clients, I need to add the Begin/End methods to the interface that is defined as the CallbackContract on my service. (I am using a sheared contract assembly, rather than generating proxy classes)
[ServiceContract(CallbackContract=typeof(IClient)]
interface IEngineManager
As the first step I have just copied the IClient interface from the shared interface assembly into a local name space, without making any other changes. I would expect that as the interface is logically the same as what is in the contract, WCF will allow it to be used. However WCF does not like it for some reason, why?
[ServiceContract]
public interface IClient
{
[OperationContract(Action = "ReceiveMessage",
ReplyAction = "ReceiveMessageResponse")]
void ReceiveMessage(SimMessage message);
}
//....
// this give the InvalidCastException
var client = OperationContext.Current.GetCallbackChannel<MyNameSpace.IClient>();
However if I just use the original IClient interface from the shared contract assembly, it all works!