Robust client and service Windows Communication Foundation (WCF) applications handle CommunicationException objects that may be thrown during communication. There are also two CommunicationException-derived exception types (FaultException<(Of <(TDetail>)>) and FaultException) that clients also often expect. Therefore, in order to prevent the generic CommunicationException handler from catching these more specific exception types, catch these exceptions prior to handling CommunicationException.
FaultException objects are thrown when a listener receives a SOAP fault that is not expected or specified in the operation contract. This usually occurs when the application is being debugged and the service has the IncludeExceptionDetailInFaults property set to true.
Note: |
|---|
When implementing custom channels and binding elements, it is strongly recommended that your components throw only System..::.TimeoutException or CommunicationException-derived objects. In the case where your components throw a recoverable exception that is specific to the component, wrap that exception inside a CommunicationException object. |
For more details about designing and using the WCF fault system, see Specifying and Handling Faults in Contracts and Services.