Freigeben über


MissingMethodException.Message Eigenschaft

Definition

Ruft die Textzeichenfolge mit dem Klassennamen, dem Methodennamen und der Signatur der fehlenden Methode ab. Diese Eigenschaft ist schreibgeschützt.

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

Eigenschaftswert

Die Fehlermeldungszeichenfolge.

Beispiele

Im folgenden Beispiel wird die Message Eigenschaft veranschaulicht. Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die MissingMethodException Klasse bereitgestellt wird.

try
{
    // Attempt to call a static DoSomething method defined in the App class.
    // However, because the App class does not define this method,
    // a MissingMethodException is thrown.
    typeof(App).InvokeMember("DoSomething", BindingFlags.Static |
        BindingFlags.InvokeMethod, null, null, null);
}
catch (MissingMethodException e)
{
    // Show the user that the DoSomething method cannot be called.
    Console.WriteLine("Unable to call the DoSomething method: {0}", e.Message);
}
try
    // Attempt to call a static DoSomething method defined in the App class.
    // However, because the App class does not define this method,
    // a MissingMethodException is thrown.
    typeof<App>.InvokeMember("DoSomething", BindingFlags.Static ||| BindingFlags.InvokeMethod, null, null, null)
    |> ignore
with :? MissingMethodException as e ->
    // Show the user that the DoSomething method cannot be called.
    printfn $"Unable to call the DoSomething method: {e.Message}"
Try
    ' Attempt to call a static DoSomething method defined in the App class.
    ' However, because the App class does not define this method, 
    ' a MissingMethodException is thrown.
    GetType(App).InvokeMember("DoSomething", BindingFlags.Static Or BindingFlags.InvokeMethod, _
                               Nothing, Nothing, Nothing)
Catch e As MissingMethodException
    ' Show the user that the DoSomething method cannot be called.
    Console.WriteLine("Unable to call the DoSomething method: {0}", e.Message)
End Try

Hinweise

Wenn der Klassenname beim Erstellen des Objekts nicht angegeben wird, wird die von der Basisklasse geerbte Standardtextzeichenfolge zurückgegeben.

Diese Eigenschaft setzt außer Kraft Message. Die Fehlermeldung sollte lokalisiert werden.

Gilt für: