WCF 中的错误处理 - 如何将错误传递给客户端以及如何将通道保持在 "Open" 状态

Errors Handling in WCF - how to pass the error to client as well as remain the channel in the "Open" state

我想实现架构,在该架构下,我的 WCF 服务中所有应用程序定义的错误都将传递给客户端,但通信通道必须保持 Open 状态。

在当前点,第一个任务是通过 IncludeExceptionDetailInFaults = true 实现的,但在第一个异常之后,通信通道状态从 Open 移动到 Fault。我怎样才能防止这种行为(服务代码中第一个异常后通信通道的损坏)?

故障通道无法关闭,无法再次使用。必须通过调用 Abort() 方法 中止 故障通道。此外,与其使用 "IncludeExceptionDetailInFaults = true",不如使用 FaultExceptions. And it is also recommended that you use the FaultContractAttribute 来设计您的服务以应对 return 强类型 SOAP 错误。