获取回调通道时抛出 NullReference 异常
我正在尝试与 WCF 的复式合同相处。本文中的代码
(http://msdn.microsoft.com/en- us/library/ms731184.aspx)
ICalculatorDuplexCallback 回调 = null; 回调=OperationContext.Current.GetCallbackChannel();
抛出 NullReferenceException。那么我该如何处理这个问题呢?
感谢您的关注!
I am trying to get along with WCF's duplex contracts. A code from this article
(http://msdn.microsoft.com/en-us/library/ms731184.aspx)
ICalculatorDuplexCallback callback = null;
callback = OperationContext.Current.GetCallbackChannel();
throws a NullReferenceException. So how can i manage this?
Thanks for your attention!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
内容装饰了 ICalculatorDuplex 的界面
您是否用以下
:当服务收到消息时,它会查看消息中的replyTo 元素以确定回复的位置,我猜如果您缺少回调契约属性,则会导致您得到一个NullReferenceException,因为它不知道在哪里回复。
Have you decorated the interface for ICalculatorDuplex
with
When a service receives a message it looks at a replyTo element in the message to determine where to reply to, I would guess that if your missing the callback contract attribute it, it would result in you getting a NullReferenceException, as it doesn't know where to replyTo.
我刚刚快速浏览了这个例子。
我的服务的代码是:
}
我的应用程序配置如下:
然后,我使用配置文件中的主机地址创建一个名为 CalculatorService 的服务引用。
所以我的客户看起来像:
I've just ran quickly through the example.
The code for my service is :
}
My application config looks like :
I then used the host address in the config file to create a service reference named CalculatorService.
so my client looks like :