无法将 Callback 对象强制转换为 System.ServiceModel.ICommunicationObject 类型
我尝试断开客户端与服务器的连接:
if (((ICommunicationObject)proxy).State == CommunicationState.Opened)
{
proxy.DisConnect();
}
它无法将实现 (IServiceCallback) 作为 ServiceContract 的类型 (ServiceCallback) 的代理强制转换为 ICommunicationObject 类型,它返回 null
public class ServiceCallback : IServiceCallback , IDisposable { /* Implementation */ }
异常:
Unable to cast object of type 'Partition.ServiceCallback' to type 'System.ServiceModel.ICommunicationObject'.
I trying to disconnect client to server:
if (((ICommunicationObject)proxy).State == CommunicationState.Opened)
{
proxy.DisConnect();
}
It can't be casting proxy of type (ServiceCallback) that implements (IServiceCallback) as ServiceContract to type ICommunicationObject , it returns null
public class ServiceCallback : IServiceCallback , IDisposable { /* Implementation */ }
Exception:
Unable to cast object of type 'Partition.ServiceCallback' to type 'System.ServiceModel.ICommunicationObject'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
ServiceCallback
类需要实现System.ServiceModel.ICommunicationObject
如果没有,就像你的情况一样,铸造将会失败。
Your
ServiceCallback
class needs to implementSystem.ServiceModel.ICommunicationObject
If it doesn't, like in your case, the casting will fail.