MissingMethodException.Message Propiedad

Definición

Obtiene la cadena de texto que muestra el nombre de la clase, el nombre del método y la firma del método que no se encuentra. Esta propiedad es de sólo lectura.

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

Valor de propiedad

String

Cadena con el mensaje de error.

Ejemplos

En el ejemplo siguiente se muestra la Message propiedad . Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la MissingMethodException clase .

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

Comentarios

Si no se especifica el nombre de clase cuando se construye el objeto, se devuelve la cadena de texto predeterminada heredada de la clase base.

Esta propiedad invalida Message. El mensaje de error debe localizarse.

Se aplica a