다음을 통해 공유


Debug.Fail 메서드

정의

오류 메시지를 내보낸다.

오버로드

Name Description
Fail(String, String)

오류 메시지와 자세한 오류 메시지를 내보낸다.

Fail(String)

지정된 오류 메시지를 내보낸다.

Fail(String, String)

Source:
Debug.cs
Source:
Debug.cs
Source:
Debug.cs
Source:
Debug.cs
Source:
Debug.cs

오류 메시지와 자세한 오류 메시지를 내보낸다.

public:
 static void Fail(System::String ^ message, System::String ^ detailMessage);
[System.Diagnostics.Conditional("DEBUG")]
public static void Fail(string message, string detailMessage);
[System.Diagnostics.Conditional("DEBUG")]
public static void Fail(string? message, string? detailMessage);
[<System.Diagnostics.Conditional("DEBUG")>]
static member Fail : string * string -> unit
Public Shared Sub Fail (message As String, detailMessage As String)

매개 변수

message
String

내보낸 메시지입니다.

detailMessage
String

내보낸 자세한 메시지입니다.

특성

예제

다음 예제에서는 예외를 처리 하는 동안 메시지를 인쇄 하는 메서드를 사용 Fail 합니다.

catch (Exception)
{
    Debug.Fail("Invalid value: " + value.ToString(),
       "Resetting value to newValue.");
    value = newValue;
}
Catch e As Exception
    Debug.Fail("Invalid value: " + value.ToString(), "Resetting value to newValue.")
    value = newValue
End Try

switch 문에서 메서드를 사용할 Fail 수도 있습니다.

switch (option1)
{
    case MyOption.First:
        result = 1.0;
        break;

    // Insert additional cases.

    default:
        Debug.Fail("Unknown Option " + option1, "Result set to 1.0");
        result = 1.0;
        break;
}
Select Case option1
    Case MyOption.First
        result = 1.0
    
    ' Insert additional cases.
    Case Else
        Debug.Fail("Unknown Option " & option1, "Result set to 1.0")
        result = 1.0
End Select

설명

기본 동작은 애플리케이션이 DefaultTraceListener 사용자 인터페이스 모드에서 실행 중일 때 메시지 상자와 컬렉션의 TraceListener 인스턴스에 Listeners 메시지를 출력하는 것입니다.

메모

메시지 상자의 표시는 .의 DefaultTraceListener존재에 따라 달라집니다. 컬렉션에 DefaultTraceListenerListeners 없는 경우 메시지 상자가 표시되지 않습니다. 지우 DefaultTraceListener기>, 제거 또는 속성()에서 메서드를 호출하여 제거할<>수 있습니다.<ClearListenersSystem.Diagnostics.Trace.Listeners.Clear()

컬렉션을 추가 TraceListener 하거나 컬렉션에서 Listeners 제거하여 이 동작을 사용자 지정할 수 있습니다.

추가 정보

적용 대상

Fail(String)

Source:
Debug.cs
Source:
Debug.cs
Source:
Debug.cs
Source:
Debug.cs
Source:
Debug.cs

지정된 오류 메시지를 내보낸다.

public:
 static void Fail(System::String ^ message);
[System.Diagnostics.Conditional("DEBUG")]
public static void Fail(string message);
[System.Diagnostics.Conditional("DEBUG")]
public static void Fail(string? message);
[<System.Diagnostics.Conditional("DEBUG")>]
static member Fail : string -> unit
Public Shared Sub Fail (message As String)

매개 변수

message
String

내보낸 메시지입니다.

특성

예제

다음 예제에서는 예외를 처리 하는 동안 메시지를 인쇄 하는 메서드를 사용 Fail 합니다.

catch (Exception)
{
    Debug.Fail("Unknown Option " + option + ", using the default.");
}
Catch e As Exception
    Debug.Fail("Unknown Option " + myOption1 + ", using the default.")
End Try

switch 문에서 메서드를 사용할 Fail 수도 있습니다.

switch (option)
{
    case Option.First:
        result = 1.0;
        break;

    // Insert additional cases.

    default:
        Debug.Fail("Unknown Option " + option);
        result = 1.0;
        break;
}
Select Case myOption1
    Case MyOption.First
        result = 1.0
    
    ' Insert additional cases.
    Case Else
        Debug.Fail(("Unknown Option " & myOption1.ToString))
        result = 1.0
End Select

설명

기본 동작은 애플리케이션이 DefaultTraceListener 사용자 인터페이스 모드에서 실행 중일 때 메시지 상자와 컬렉션의 TraceListener 인스턴스에 Listeners 메시지를 출력하는 것입니다.

메모

메시지 상자의 표시는 .의 DefaultTraceListener존재에 따라 달라집니다. 컬렉션에 DefaultTraceListenerListeners 없는 경우 메시지 상자가 표시되지 않습니다. 지우 DefaultTraceListener기>, 제거 또는 속성()에서 메서드를 호출하여 제거할<>수 있습니다.<ClearListenersSystem.Diagnostics.Trace.Listeners.Clear()

컬렉션을 추가 TraceListener 하거나 컬렉션에서 Listeners 제거하여 이 동작을 사용자 지정할 수 있습니다.

추가 정보

적용 대상