CallbackBehaviorAttribute.IncludeExceptionDetailInFaults CallbackBehaviorAttribute.IncludeExceptionDetailInFaults CallbackBehaviorAttribute.IncludeExceptionDetailInFaults CallbackBehaviorAttribute.IncludeExceptionDetailInFaults Property

定義

一般的な未処理の実行例外を FaultException<TDetail> 型の String に変換してエラー メッセージとして送信するように指定する値を取得または設定します。Gets or sets a value that specifies that general unhandled execution exceptions are to be converted into a FaultException<TDetail> of type String and sent as a fault message. この属性は、開発時にサービスのトラブルシューティングを行う場合にのみ、true に設定します。Set this to true only during development to troubleshoot a service.

public:
 property bool IncludeExceptionDetailInFaults { bool get(); void set(bool value); };
public bool IncludeExceptionDetailInFaults { get; set; }
member this.IncludeExceptionDetailInFaults : bool with get, set
Public Property IncludeExceptionDetailInFaults As Boolean

プロパティ値

未処理の例外を SOAP エラーとして返す場合は true、それ以外の場合は falsetrue if unhandled exceptions are to be returned as SOAP faults; otherwise, false. 既定値は、false です。The default is false.

CallbackBehaviorAttribute オブジェクトを使用してマーシャリングするスレッドを決定するコールバック オブジェクトの SynchronizationContext、メッセージ検証を実施する ValidateMustUnderstand プロパティ、および例外を IncludeExceptionDetailInFaults オブジェクトとしてデバッグ用のサービスに返す FaultException プロパティのコード例を次に示します。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
{
  [CallbackBehaviorAttribute(
   IncludeExceptionDetailInFaults= true, 
    UseSynchronizationContext=true,
    ValidateMustUnderstand=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");
      try
      {
        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);
        wcfClient.Hello(greeting);
        Console.WriteLine("Execution passes service call and moves to the WaitHandle.");
        this.waitHandle.WaitOne();
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.WriteLine("Set was called.");
        Console.Write("Press ");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write("ENTER");
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.Write(" to exit...");
        Console.ReadLine();
      }
      catch (TimeoutException timeProblem)
      {
        Console.WriteLine("The service operation timed out. " + timeProblem.Message);
        Console.ReadLine();
      }
      catch (CommunicationException commProblem)
      {
        Console.WriteLine("There was a communication problem. " + commProblem.Message);
        Console.ReadLine();
      }
    }
    public static void Main()
    {
      Client client = new Client();
      client.Run();
    }

    public void Reply(string response)
    {
      Console.WriteLine("Received output.");
      Console.WriteLine("\r\n\t" + response);
      this.waitHandle.Set();
    }
  }
}

Imports Microsoft.VisualBasic
Imports System
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.Threading

Namespace Microsoft.WCF.Documentation
  <CallbackBehaviorAttribute(IncludeExceptionDetailInFaults:= True, UseSynchronizationContext:=True, ValidateMustUnderstand:=True)> _
  Public Class Client
	  Implements SampleDuplexHelloCallback
	Private waitHandle As AutoResetEvent

	Public Sub New()
	  waitHandle = New AutoResetEvent(False)
	End Sub

	Public Sub Run()
	  ' Picks up configuration from the configuration file.
	  Dim wcfClient As New SampleDuplexHelloClient(New InstanceContext(Me), "WSDualHttpBinding_SampleDuplexHello")
	  Try
		Console.ForegroundColor = ConsoleColor.White
		Console.WriteLine("Enter a greeting to send and press ENTER: ")
		Console.Write(">>> ")
		Console.ForegroundColor = ConsoleColor.Green
		Dim greeting As String = Console.ReadLine()
		Console.ForegroundColor = ConsoleColor.White
		Console.WriteLine("Called service with: " & Constants.vbCrLf & Constants.vbTab & greeting)
		wcfClient.Hello(greeting)
		Console.WriteLine("Execution passes service call and moves to the WaitHandle.")
		Me.waitHandle.WaitOne()
		Console.ForegroundColor = ConsoleColor.Blue
		Console.WriteLine("Set was called.")
		Console.Write("Press ")
		Console.ForegroundColor = ConsoleColor.Red
		Console.Write("ENTER")
		Console.ForegroundColor = ConsoleColor.Blue
		Console.Write(" to exit...")
		Console.ReadLine()
	  Catch timeProblem As TimeoutException
		Console.WriteLine("The service operation timed out. " & timeProblem.Message)
		Console.ReadLine()
	  Catch commProblem As CommunicationException
		Console.WriteLine("There was a communication problem. " & commProblem.Message)
		Console.ReadLine()
	  End Try
	End Sub
	Public Shared Sub Main()
	  Dim client As New Client()
	  client.Run()
	End Sub

	Public Sub Reply(ByVal response As String) Implements SampleDuplexHelloCallback.Reply
	  Console.WriteLine("Received output.")
	  Console.WriteLine(Constants.vbCrLf & Constants.vbTab & response)
	  Me.waitHandle.Set()
	End Sub
  End Class
End Namespace

注釈

可能な場合に例外情報をデバッグ用にサービスに返すことを有効にするには、IncludeExceptionDetailInFaultstrue に設定します。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. これらのエラーは、呼び出し元で FaultException オブジェクトとして出現します。These faults appear to the calling service as FaultException objects.

重要

設定IncludeExceptionDetailInFaultstrueにより、内部クライアント コールバック例外に関する情報を取得するサービスの双方向クライアント アプリケーションを一時的にデバッグする方法としてのみお勧めします。Setting IncludeExceptionDetailInFaults to 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.

適用対象