Language

ServiceDebugBehavior.IncludeExceptionDetailInFaults プロパティ

定義

デバッグ目的でクライアントに返される SOAP エラーの詳細にマネージド例外情報を含めるかどうかを指定する値を取得または設定します。

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

プロパティ値

true Windows Communication Foundation (WCF) がクライアント デバッグのために SOAP エラーでマネージド例外情報を返す場合。それ以外の場合は false。 既定値は false です。

例

次のコード例は、構成ファイルを使用して HTML ヘルプ ページ機能を有効にし、デバッグのために SOAP エラー内の例外情報をクライアントに返す方法を示しています。 この構成ファイルは、 ServiceDebugBehavior 機能のサポートを追加するための次の基本的な手順を示しています。

<configuration>
  <system.serviceModel>
    <services>
      <!-- 
        Step 1. Add a behaviorConfiguration attribute
        in the <service> element.
      -->
      <service 
        name="Microsoft.WCF.Documentation.SampleService"
        behaviorConfiguration="metadataAndDebug">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/SampleService" />
          </baseAddresses>
        </host>
        <endpoint
          address=""
          binding="wsHttpBinding"
          contract="Microsoft.WCF.Documentation.ISampleService"
        />
        <endpoint
           address="mex"
           binding="mexHttpBinding"
           contract="IMetadataExchange"
        />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <!-- 
          Step 2. Inside a <serviceBehaviors> section, add 
          a name attribute in the <behaviors> element that 
          matches the behaviorConfiguration attribute in the
          <service> element above.
        -->
        <behavior name="metadataAndDebug">
          <serviceMetadata 
            httpGetEnabled="true" 
            httpGetUrl=""
          />
          <!-- 
            Step 3. Add a <serviceDebug> element and 
            modify the various attributes that suit your 
            scenario.
          -->
          <serviceDebug 
            httpHelpPageEnabled="true" 
            includeExceptionDetailInFaults="true"
          />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

注釈

デバッグを容易にするために、 プロパティを に設定して、マネージ例外情報を SOAP エラーでクライアントに返すように WCF に指示します。

Caution

例外の詳細では、承認されていないクライアントが使用できる内部サービスの実装に関する情報が公開されるため、マネージド例外情報をクライアントに返すことはセキュリティ 上のリスクになる可能性があります。 また、 ServiceDebugBehavior プロパティはプログラムで設定することもできますが、デプロイ時に IncludeExceptionDetailInFaults を無効にすることを忘れやすい場合があります。

セキュリティの問題が発生するため、次の点を強くお勧めします。

  • アプリケーション構成ファイルを使用して、 IncludeExceptionDetailInFaults プロパティの値を trueに設定します。

  • これは、制御されたデバッグ シナリオでのみ行います。

詳細については、「 コントラクトとサービスでのエラーの指定と処理」を参照してください。

適用対象