英語で読む

次の方法で共有


MissingMemberException.Message プロパティ

定義

存在しないメンバのクラス名、メンバ名、およびシグネチャを示す文字列を取得します。

C#
public override string Message { get; }

プロパティ値

String

エラー メッセージ文字列。

Messageプロパティの例を次に示します。 このコード例は、MissingMemberException クラスのために提供されている大規模な例の一部です。

C#
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);
}

注釈

オブジェクトの構築時にクラス名が指定されていない場合は、基底クラスから継承された既定のテキスト文字列が返されます。

このプロパティはオーバーライドします Message。 エラー メッセージはローカライズする必要があります。

このプロパティは読み取り専用です。

適用対象

製品 バージョン
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

こちらもご覧ください