FaultException<(Of <(TDetail>)>) Class

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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

Inheritance Hierarchy

System..::.Object
System..::.Exception
System..::.SystemException
System.ServiceModel..::.CommunicationException
System.ServiceModel..::.FaultException
System.ServiceModel..::.FaultException<(Of <(TDetail>)>)

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

Syntax

Public Class FaultException(Of TDetail) _
    Inherits FaultException
public class FaultException<TDetail> : FaultException

Type Parameters

  • TDetail
    The serializable error detail type.

The FaultException<(Of <(TDetail>)>) type exposes the following members.

Constructors

Name Description
FaultException<(Of <(TDetail>)>) Initializes a new instance of the FaultException<(Of <(TDetail>)>) class that uses a specified detail object and SOAP fault reason, code and action values.

Top

Properties

Name Description
Action Gets the value of the SOAP action for the fault message. (Inherited from FaultException.)
Code Gets the fault code for the SOAP fault. (Inherited from FaultException.)
Data Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from Exception.)
Detail Gets the object that contains the detail information of the fault condition.
HelpLink Gets or sets a link to the help file associated with this exception. (Inherited from Exception.)
HResult Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (Inherited from Exception.)
InnerException Gets the Exception instance that caused the current exception. (Inherited from Exception.)
Message Gets the message for the exception. (Inherited from FaultException.)
Reason Gets the FaultReason for the SOAP fault. (Inherited from FaultException.)
Source Gets or sets the name of the application or the object that causes the error. (Inherited from Exception.)
StackTrace Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from Exception.)

Top

Methods

Name Description
CreateMessageFault Returns an in-memory MessageFault object. (Inherited from FaultException.)
Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
GetBaseException When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Inherited from Exception.)
GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
GetType Gets the runtime type of the current instance. (Inherited from Exception.)
MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
ToString Returns a string for the FaultException<(Of <(TDetail>)>) object. (Overrides Exception..::.ToString()()().)

Top

Remarks

Catch the FaultException<(Of <(TDetail>)>) object in a Windows Phone 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<(Of <(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<(Of <(TDetail>)>) is both a FaultException and therefore a CommunicationException, to catch specified SOAP faults make sure you catch the FaultException<(Of <(TDetail>)>) types prior to the FaultException and CommunicationException types or handle the specified exceptions in one of those exception handlers.

Note

If you use System.ServiceModel..::.FaultContractAttribute to specify a FaultException<(Of <(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<(Of <(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.

Capabilities

If you use this API in your app, you must specify the following capabilities in the app manifest. Otherwise, your app might not work correctly or it might exit unexpectedly.

ID_CAP_NETWORKING

Windows Phone 8, Windows Phone OS 7.1

For more info, see App capabilities and hardware requirements for Windows Phone 8.

Examples

The following code example shows how a service uses the FaultException<(Of <(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<(Of <(TDetail>)>) type that represents the custom SOAP fault specified in the operation contract.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

Thread Safety

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

See Also

Reference

System.ServiceModel Namespace