Assembly: System.ServiceModel (in system.servicemodel.dll)
Use the MessageFault class any time you need an in-memory SOAP fault that can be modified and used to create a SOAP message that contains the fault information.
Typically, the MessageFault class is used when implementing the IErrorHandler interface. In this case, Windows Communication Foundation (WCF) passes the MessageFault object and you use it for your specific needs (for example, you can customize the MessageFault or to log fault information). However, MessageFault can be used anywhere custom SOAP fault message handling is required.
The following code example shows the most common use of MessageFault. Both the ProvideFault and HandleError pass in a MessageFault object that can be modified and returned to the system (in the case of ProvideFault) or used to perform some custom fault-related behavior (in the case of HandleError).
In this example, the ProvideFault method converts all Exception objects into a MessageFault object that contains a FaultException object of type GreetingFault and returns that customized MessageFault to WCF.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionMicrosoft .NET Framework 3.0 wird unter Windows Vista, Microsoft Windows XP SP2 und Windows Server 2003 SP1 unterstützt.