MissingMemberException.Message 속성

정의

클래스 이름, 멤버 이름, 누락된 멤버의 서명을 표시하는 텍스트 문자열을 가져옵니다.

public:
 virtual property System::String ^ Message { System::String ^ get(); };
public override string Message { get; }
member this.Message : string
Public Overrides ReadOnly Property Message As String

속성 값

String

오류 메시지 문자열입니다.

예제

다음 예제는 Message 속성입니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 MissingMemberException 클래스입니다.

try
{
    // Attempt to access a static AnotherField field defined in the App class.
    // However, because the App class does not define this field,
    // a MissingFieldException is thrown.
    App::typeid->InvokeMember("AnotherField", BindingFlags::Static |
        BindingFlags::GetField, nullptr, nullptr, nullptr);
}
catch (MissingMemberException^ ex)
{
    // Notice that this code is catching MissingMemberException which is the
    // base class of MissingMethodException and MissingFieldException.
    // Show the user that the AnotherField field cannot be accessed.
    Console::WriteLine("Unable to access the AnotherField field: {0}",
        ex->Message);
}
try
{
    // Attempt to access a static AnotherField field defined in the App class.
    // However, because the App class does not define this field,
    // a MissingFieldException is thrown.
    typeof(App).InvokeMember("AnotherField", BindingFlags.Static |
        BindingFlags.GetField, null, null, null);
}
catch (MissingMemberException e)
{
 // Notice that this code is catching MissingMemberException which is the
 // base class of MissingMethodException and MissingFieldException.
 // Show the user that the AnotherField field cannot be accessed.
 Console.WriteLine("Unable to access the AnotherField field: {0}", e.Message);
}
try
    // Attempt to access a static AnotherField field defined in the App class.
    // However, because the App class does not define this field,
    // a MissingFieldException is thrown.
    typeof<App>.InvokeMember("AnotherField", BindingFlags.Static ||| BindingFlags.GetField, null, null, null)
    |> ignore
with :? MissingMemberException as e ->
    // Notice that this code is catching MissingMemberException which is the
    // base class of MissingMethodException and MissingFieldException.
    // Show the user that the AnotherField field cannot be accessed.
    printfn $"Unable to access the AnotherField field: {e.Message}"
    Try
        ' Attempt to access a static AnotherField field defined in the App class.
        ' However, because the App class does not define this field, 
        ' a MissingFieldException is thrown.
        GetType(App).InvokeMember("AnotherField", BindingFlags.Static Or BindingFlags.GetField, _
                                   Nothing, Nothing, Nothing)
    Catch e As MissingMemberException
        ' Notice that this code is catching MissingMemberException which is the  
        ' base class of MissingMethodException and MissingFieldException.
        ' Show the user that the AnotherField field cannot be accessed.
        Console.WriteLine("Unable to access the AnotherField field: {0}", e.Message)
    End Try
End Sub

설명

개체가 생성될 때 클래스 이름을 지정하지 않으면 기본 클래스에서 상속된 기본 텍스트 문자열이 반환됩니다.

이 속성은 재정의합니다.Message 오류 메시지는 지역화되어야 합니다.

이 속성은 읽기 전용입니다.

적용 대상

추가 정보