MissingMethodException.Message 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取显示类名、方法名称和缺少方法签名的文本字符串。 此属性为只读。
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
属性值
错误消息字符串。
示例
以下示例演示了该 Message 属性。 此代码示例是为类提供的大型示例的 MissingMethodException 一部分。
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
注解
如果在构造对象时未指定类名,则返回从基类继承的默认文本字符串。
此属性替代 Message。 错误消息应本地化。