Export (0) Print
Expand All

FaultException<TDetail> Class

Used in a client application to catch contractually specified SOAP faults.

System.Object
  System.Exception
    System.SystemException
      System.ServiceModel.CommunicationException
        System.ServiceModel.FaultException
          System.ServiceModel.FaultException<TDetail>

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public class FaultException<TDetail> : FaultException

Type Parameters

TDetail

The serializable error detail type.

The FaultException<TDetail> type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneFaultException<TDetail>Initializes a new instance of the FaultException<TDetail> class that uses a specified detail object and SOAP fault reason, code and action values.
Top

  NameDescription
Public propertySupported by Silverlight for Windows PhoneActionGets the value of the SOAP action for the fault message. (Inherited from FaultException.)
Public propertySupported by Silverlight for Windows PhoneCodeGets the fault code for the SOAP fault. (Inherited from FaultException.)
Public propertySupported by Silverlight for Windows PhoneDataGets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from Exception.)
Public propertySupported by Silverlight for Windows PhoneDetailGets the object that contains the detail information of the fault condition.
Protected propertySupported by Silverlight for Windows PhoneHResultGets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from Exception.)
Public propertySupported by Silverlight for Windows PhoneInnerExceptionGets the Exception instance that caused the current exception. (Inherited from Exception.)
Public propertySupported by Silverlight for Windows PhoneMessageGets the message for the exception. (Inherited from FaultException.)
Public propertySupported by Silverlight for Windows PhoneReasonGets the FaultReason for the SOAP fault. (Inherited from FaultException.)
Public propertySupported by Silverlight for Windows PhoneStackTraceGets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from Exception.)
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneCreateMessageFaultReturns an in-memory MessageFault object. (Inherited from FaultException.)
Public methodSupported by Silverlight for Windows PhoneEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetBaseExceptionWhen overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Inherited from Exception.)
Public methodSupported by Silverlight for Windows PhoneGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetTypeGets the runtime type of the current instance. (Inherited from Exception.)
Protected methodSupported by Silverlight for Windows PhoneMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneToStringReturns a string for the FaultException<TDetail> object. (Overrides Exception.ToString().)
Top

Catch the FaultException<TDetail> object in a Silverlight client application to handle a SOAP fault that has been contractually specified in an operation contract.

Typical deployed services use the FaultContractAttribute to formally specify all SOAP faults that a client can expect to receive in the normal course of an operation. Error information in a FaultContractAttribute appears as a FaultException<TDetail> (where the type parameter is the serializable error object specified in the operation's FaultContractAttribute) when it arrives at a client application. The FaultContractAttribute can be used to specify SOAP faults for both two-way service methods and for asynchronous method pairs.

Because FaultException<TDetail> is both a FaultException and therefore a CommunicationException, to catch specified SOAP faults make sure you catch the FaultException<TDetail> types prior to the FaultException and CommunicationException types or handle the specified exceptions in one of those exception handlers.

NoteNote:

If you use System.ServiceModel.FaultContractAttribute to specify a FaultException<TDetail> where the type parameter is a System.String, the string value is assigned to the Detail property in the client application; clients cannot retrieve that string by calling the FaultException<TDetail>.ToString method. To have the string value returned when the client application calls Exception.ToString, throw a System.ServiceModel.FaultException exception inside the operation and pass the string to the constructor. In general, it is recommended that detail types be custom serializable types appropriate to the fault and not a System.String.

The following code example shows how a service uses the FaultException<TDetail> type to throw a managed exception that gets converted into the SOAP fault specified by the FaultContractAttribute.

The following code example shows how the client code looks when imported by the client using the SLsvcutil.exe.

The following code example shows how a client can catch the FaultException<TDetail> type that represents the custom SOAP fault specified in the operation contract.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft