CallbackBehaviorAttribute.IncludeExceptionDetailInFaults Property

Gets or sets a value that specifies that general unhandled execution exceptions are to be converted into a FaultException of type String and sent as a fault message. Set this to true only during development to troubleshoot a service.

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

public bool IncludeExceptionDetailInFaults { get; set; }
/** @property */
public boolean get_IncludeExceptionDetailInFaults ()

/** @property */
public void set_IncludeExceptionDetailInFaults (boolean value)

public function get IncludeExceptionDetailInFaults () : boolean

public function set IncludeExceptionDetailInFaults (value : boolean)

Not applicable.

Property Value

true if unhandled exceptions are to be returned as SOAP faults; otherwise, false. The default is false.

Set IncludeExceptionDetailInFaults to true to enable exception information to flow back to services for debugging purposes when possible. This is a development-only feature and should not be employed in deployed services. These faults appear to the calling service as FaultException objects.

Important   Setting IncludeExceptionDetailInFaultsto true enables services to obtain information about internal client callback exceptions; it is only recommended as a way of temporarily debugging a duplex client application.

The following code example shows a CallbackBehaviorAttribute on a callback object that uses the SynchronizationContext object to determine which thread to marshal to, the ValidateMustUnderstand property to enforce message validation, and the IncludeExceptionDetailInFaults property to return exceptions as FaultException objects to the service for debugging purposes.

using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Threading;

namespace Microsoft.WCF.Documentation
   IncludeExceptionDetailInFaults= true, 
  public class Client : SampleDuplexHelloCallback
    AutoResetEvent waitHandle;

    public Client()
      waitHandle = new AutoResetEvent(false);

    public void Run()
      // Picks up configuration from the configuration file.
      SampleDuplexHelloClient wcfClient
        = new SampleDuplexHelloClient(new InstanceContext(this), "WSDualHttpBinding_SampleDuplexHello");
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("Enter a greeting to send and press ENTER: ");
        Console.Write(">>> ");
        Console.ForegroundColor = ConsoleColor.Green;
        string greeting = Console.ReadLine();
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("Called service with: \r\n\t" + greeting);
        Console.WriteLine("Execution passes service call and moves to the WaitHandle.");
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.WriteLine("Set was called.");
        Console.Write("Press ");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.Write(" to exit...");
      catch (TimeoutException timeProblem)
        Console.WriteLine("The service operation timed out. " + timeProblem.Message);
      catch (CommunicationException commProblem)
        Console.WriteLine("There was a communication problem. " + commProblem.Message);
    public static void Main()
      Client client = new Client();

    public void Reply(string response)
      Console.WriteLine("Received output.");
      Console.WriteLine("\r\n\t" + response);

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions