开发者

Will throwing a WCF Fault in a IsTerminating=true method still close the channel

I have a WCF ser开发者_高级运维vice that is using SessionMode.Required for state. I have a method that will terminal the channel if called (IsTerminating=true). However I only want to terminate if certain conditions are met. If I throw a fault will the channel still close? If so, what is the best way to handle this scenario.


Yes, the channel is closed after any reply is sent, regardless of whether it was a fault or not.

It seems you only have two options to deal with this:

  1. Don't mark the operation IsTerminating (since it is not Terminating - according to the .Net meaning) and instead create an alternative terminal operation.
  2. Catch all exceptions to prevent the fault being thrown. However, you may then need to come up with an alternative mechanism to communicate faults back to the client.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜