CommunicationException 클래스

정의

서비스 또는 클라이언트 애플리케이션의 통신 오류를 나타냅니다.

public ref class CommunicationException : Exception
public ref class CommunicationException : SystemException
public class CommunicationException : Exception
[System.Serializable]
public class CommunicationException : SystemException
type CommunicationException = class
    inherit Exception
[<System.Serializable>]
type CommunicationException = class
    inherit SystemException
Public Class CommunicationException
Inherits Exception
Public Class CommunicationException
Inherits SystemException
상속
CommunicationException
상속
CommunicationException
파생
특성

예제

다음 코드 예제에서는 형식을 처리하는 클라이언트를 보여 줍니다 CommunicationException . 서비스가 .로 설정되었으므로 이 클라이언트는 IncludeExceptionDetailInFaults 개체도 처리 FaultException 합니다true.

using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using Microsoft.WCF.Documentation;

public class Client
{
  public static void Main()
  {
    // Picks up configuration from the configuration file.
    SampleServiceClient wcfClient = new SampleServiceClient();
    try
    {
      // Making calls.
      Console.WriteLine("Enter the greeting to send: ");
      string greeting = Console.ReadLine();
      Console.WriteLine("The service responded: " + wcfClient.SampleMethod(greeting));
      Console.WriteLine("Press ENTER to exit:");
      Console.ReadLine();
    }
    catch (TimeoutException timeProblem)
    {
      Console.WriteLine("The service operation timed out. " + timeProblem.Message);
      wcfClient.Abort();
      Console.ReadLine();
    }
    // Catch the contractually specified SOAP fault raised here as an exception.
    catch (FaultException<GreetingFault> greetingFault)
    {
      Console.WriteLine(greetingFault.Detail.Message);
      Console.Read();
      wcfClient.Abort();
    }
    // Catch unrecognized faults. This handler receives exceptions thrown by WCF
    // services when ServiceDebugBehavior.IncludeExceptionDetailInFaults
    // is set to true.
    catch (FaultException faultEx)
    {
      Console.WriteLine("An unknown exception was received. "
        + faultEx.Message
        + faultEx.StackTrace
      );
      Console.Read();
      wcfClient.Abort();
    }
    // Standard communication fault handler.
    catch (CommunicationException commProblem)
    {
      Console.WriteLine("There was a communication problem. " + commProblem.Message + commProblem.StackTrace);
      Console.Read();
      wcfClient.Abort();
    }
  }
}

Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports Microsoft.WCF.Documentation

Public Class Client
  Public Shared Sub Main()
    ' Picks up configuration from the configuration file.
    Dim wcfClient As New SampleServiceClient()
    Try
      ' Making calls.
      Console.WriteLine("Enter the greeting to send: ")
      Dim greeting As String = Console.ReadLine()
      Console.WriteLine("The service responded: " & wcfClient.SampleMethod(greeting))
      Console.WriteLine("Press ENTER to exit:")
      Console.ReadLine()
    Catch timeProblem As TimeoutException
      Console.WriteLine("The service operation timed out. " & timeProblem.Message)
      wcfClient.Abort()
      Console.ReadLine()
    ' Catch the contractually specified SOAP fault raised here as an exception.
    Catch greetingFault As FaultException(Of GreetingFault)
      Console.WriteLine(greetingFault.Detail.Message)
      Console.Read()
      wcfClient.Abort()
    ' Catch unrecognized faults. This handler receives exceptions thrown by WCF
    ' services when ServiceDebugBehavior.IncludeExceptionDetailInFaults 
    ' is set to true.
    Catch faultEx As FaultException
      Console.WriteLine("An unknown exception was received. " & faultEx.Message + faultEx.StackTrace)
      Console.Read()
      wcfClient.Abort()
    ' Standard communication fault handler.
    Catch commProblem As CommunicationException
      Console.WriteLine("There was a communication problem. " & commProblem.Message + commProblem.StackTrace)
      Console.Read()
      wcfClient.Abort()
    End Try
  End Sub
End Class

설명

강력한 클라이언트 및 서비스 Windows Communication Foundation (WCF) 애플리케이션 핸들 CommunicationException 통신 중 throw 될 수 있는 개체입니다. 클라이언트도 종종 예상하는 두 CommunicationException가지 파생 예외 형식(FaultException<TDetail>FaultException)이 있습니다. 따라서 제네릭 CommunicationException 처리기가 이러한 보다 구체적인 예외 형식을 catch하지 못하도록 하려면 처리하기 전에 이러한 예외를 catch합니다 CommunicationException.

FaultException 개체는 수신기가 작업 계약에서 예상되거나 지정되지 않은 SOAP 오류를 수신할 때 throw됩니다. 이러한 상황은 애플리케이션이 디버깅 중이고 서비스에서 IncludeExceptionDetailInFaults 속성을 true로 설정한 경우에 주로 발생합니다.

참고

사용자 지정 채널 및 바인딩 요소를 구현할 때 구성 요소에서만 System.TimeoutException 또는 CommunicationException파생된 개체를 throw하는 것이 좋습니다. 구성 요소가 구성 요소와 관련된 복구 가능한 예외를 throw하는 경우 해당 예외를 개체 내부에 CommunicationException 래핑합니다.

WCF 오류 시스템을 디자인하고 사용하는 방법에 대한 자세한 내용은 계약 및 서비스에서 오류 지정 및 처리를 참조하세요.

중요

WCF 런타임은 WCF 런타임을 벗어나 사용자 코드를 입력하는 지점에서 처리하기에 안전하지 않은 값을 throw CommunicationException 하지 않습니다.

생성자

CommunicationException()

CommunicationException 클래스의 새 인스턴스를 초기화합니다.

CommunicationException(SerializationInfo, StreamingContext)

지정된 serialization 정보와 컨텍스트 개체를 사용하여 CommunicationException 클래스의 새 인스턴스를 초기화합니다.

CommunicationException(String)

지정된 메시지를 사용하여 CommunicationException 클래스의 새 인스턴스를 초기화합니다.

CommunicationException(String, Exception)

지정된 메시지와 내부 예외를 사용하여 CommunicationException 클래스의 새 인스턴스를 초기화합니다.

속성

Data

예외에 대한 사용자 정의 정보를 추가로 제공하는 키/값 쌍 컬렉션을 가져옵니다.

(다음에서 상속됨 Exception)
HelpLink

이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
HResult

특정 예외에 할당된 코드화된 숫자 값인 HRESULT를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
InnerException

현재 예외를 발생시킨 Exception 인스턴스를 가져옵니다.

(다음에서 상속됨 Exception)
Message

현재 예외를 설명하는 메시지를 가져옵니다.

(다음에서 상속됨 Exception)
Source

오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
StackTrace

호출 스택의 직접 실행 프레임 문자열 표현을 가져옵니다.

(다음에서 상속됨 Exception)
TargetSite

현재 예외를 throw하는 메서드를 가져옵니다.

(다음에서 상속됨 Exception)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetBaseException()

파생 클래스에서 재정의된 경우 하나 이상의 후속 예외의 근본 원인이 되는 Exception 을 반환합니다.

(다음에서 상속됨 Exception)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetObjectData(SerializationInfo, StreamingContext)

파생 클래스에서 재정의된 경우 예외에 관한 정보를 SerializationInfo 에 설정합니다.

(다음에서 상속됨 Exception)
GetType()

현재 인스턴스의 런타임 형식을 가져옵니다.

(다음에서 상속됨 Exception)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 예외에 대한 문자열 표현을 만들고 반환합니다.

(다음에서 상속됨 Exception)

이벤트

SerializeObjectState
사용되지 않습니다.

예외에 대한 serialize된 데이터가 들어 있는 예외 상태 개체가 만들어지도록 예외가 serialize될 때 발생합니다.

(다음에서 상속됨 Exception)

적용 대상