0

我正在使用DuplexChannelFactory而不是生成的代理创建 WCF 客户端通道。

对于一个特定的方法,我FaultException<MyFault>在服务器端抛出一个已知的。我已根据需要标记了服务接口[FaultContract(typeof(MyFault))]

在客户端,我发现了这个FaultException<MyFault>并显示了一个错误。

所有这些工作都很好,但由于某种原因,WCF 在将控制权返回给我的客户端代码之前重试了服务调用 5 次。这会导致客户端出现明显的延迟。

在继续执行我的代码的下一行之前,调试器在我的客户端代码中的服务调用中中断了 5 次。我无法进入它,但调用堆栈显示异常在 WCF 深处引发。

服务端的断点只触发一次。

一旦控制权返回给我,通道就不会出现故障。

调试器输出显示:

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in MyService.dll

Additional information: Fault Test

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll

Additional information: Fault Test

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll

Additional information: Fault Test

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll

Additional information: Fault Test

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in System.ServiceModel.dll

Additional information: Fault Test

A first chance exception of type 'System.ServiceModel.FaultException`1' occurred in mscorlib.dll

Additional information: Fault Test

这是正常行为吗?当我返回一个已知的预期错误时,为什么 WCF 会重试?

4

0 回答 0