为什么 ProvideFault 会捕获我的 TimeoutException?
我有一个通过 wcf 进行通信的 ProvideFault()
服务。对于大多数异常,我们希望捕获它们,将它们转换为 FaultException
,并让调用者处理它,因此我们实现了 ProvideFault()
。
到目前为止,一切都很好,而且大部分都有效。但是这个服务正在调用另一个服务,有时会抛出TimeoutException
;我们不想捕获该异常,而是让它冒泡给调用者(或者甚至在必要时抛出一个新的 TimeoutException )。问题是,当该方法抛出 TimeoutException
时,ProvideFault()
会尝试处理它并将其转换为FaultException。
如何强制 wcf 让它以 TimeoutException
的形式冒泡?
I've got a ProvideFault()
service that communicates through wcf. For most exceptions, we want to catch them, convert them into a FaultException<CustomException>
, and let the caller handler it, so we've implemented ProvideFault()
.
So far, so good, and it mostly works. But this service is calling another service, which sometimes throws a TimeoutExeption
; we don't want to catch that exception, but instead let it bubble up to the caller (or even throw a new TimeoutException
, if necessary). The problem is that when the method throws a TimeoutException
, ProvideFault()
tries to deal with it and turn it into a FaultException.
How do I force wcf to let it bubble up as a TimeoutException
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WCF 将异常作为FaultException 发送,因此您无法冒泡超时异常。
然而,您可以做的是发送:
WCF sends exceptions as FaultExceptions, so you cannot bubble up a Timeout Exception.
What you can do however is to send up a: