MissingMethodException.Message Proprietà

Definizione

Recupera la stringa che mostra il nome della classe, il nome del metodo e la firma del metodo mancante. Questa proprietà è di sola lettura.

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

Valore della proprietà

String

Stringa del messaggio di errore.

Esempio

Nell'esempio seguente viene illustrata la Message proprietà . Questo esempio di codice fa parte di un esempio più ampio fornito per la MissingMethodException classe .

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.
    App::typeid->InvokeMember("DoSomething", BindingFlags::Static |
        BindingFlags::InvokeMethod, nullptr, nullptr, nullptr);
}
catch (MissingMethodException^ ex)
{
    // Show the user that the DoSomething method cannot be called.
    Console::WriteLine("Unable to call the DoSomething method: {0}",
        ex->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);
}
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

Commenti

Se il nome della classe non viene specificato quando l'oggetto viene costruito, viene restituita la stringa di testo predefinita ereditata dalla classe base.

Questa proprietà esegue l'override di Message. Il messaggio di errore deve essere localizzato.

Si applica a