我尝试断开客户端与服务器的连接:
if (((ICommunicationObject)proxy).State == CommunicationState.Opened)
{
proxy.DisConnect();
}
它不能将实现(IServiceCallback)的类型(ServiceCallback)的代理转换为ServiceContract来键入ICommunicationObject,它返回null
public class ServiceCallback : IServiceCallback , IDisposable { /* Implementation */ }
例外:
Unable to cast object of type 'Partition.ServiceCallback' to type 'System.ServiceModel.ICommunicationObject'.
答案 0 :(得分:1)
您的ServiceCallback
课程需要实施System.ServiceModel.ICommunicationObject
如果没有,就像在你的情况下,铸造会失败。