WCF双工通信问题: 向 ChannelFactory 提供的 InstanceContext 包含未实现 CallbackContractType
WCF双工通信问题: 向 ChannelFactory 提供的 InstanceContext 包含未实现 CallbackContractType
服务端和客户端的回调接口定义如下:
[System.ServiceModel.ServiceContract]
public interface ICallBack
{
[OperationContract]
void SendMsg(string msg);
}
然后在客户端实现该接口:
public class ClientCallBacks : CallBackContract.ICallBack
{
public void SendMsg(string msg)
{
MessageBox.Show(msg);
}
}
然而客户端调用WCF服务器时却出现错误:
private void button1_Click(object sender, EventArgs e)
{
ClientCallBacks back = new ClientCallBacks();
InstanceContext lo_context = new InstanceContext(back);
ServiceReference1.MyWCFSvcClient a = new ServiceReference1.MyWCFSvcClient(lo_context);
a.GetMsg("中华人民共和国");
}
向 ChannelFactory 提供的 InstanceContext 包含未实现 CallbackContractType“Client.ServiceReference1.MyWCFSvcCallback”的 UserObject。
------解决方案--------------------
http://blog.csdn.net/fangxinggood/archive/2011/01/15/6142861.aspx