简体   繁体   中英

How to Catch Exceptions in WPF when Calling a WCF Service

调用WCF服务时如何在WPF中捕获异常?

Basically you'll have three approaches:

  • Rethrow FaultException on your regular try/catch
  • Mark your OperationContract with FaultContract attribute and translate your Exception to your custom Fault object, manually
  • To implement a IErrorHandler behavior and let it handle WCF exceptions to you

This link can explain these options: Simplifying WCF: Using Exceptions as Faults

I think this has already been covered by this question on stack overflow. WPF Exceptions

Bob.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM