MissingMethodException クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MissingMethodException クラスの意味・解説 

MissingMethodException クラス

存在しないメソッド動的にアクセスようとした場合スローされる例外

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class MissingMethodException
    Inherits MissingMemberException
    Implements ISerializable
Dim instance As MissingMethodException
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public class MissingMethodException : MissingMemberException,
 ISerializable
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class MissingMethodException : public
 MissingMemberException, ISerializable
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public class MissingMethodException extends
 MissingMemberException implements ISerializable
SerializableAttribute 
ComVisibleAttribute(true) 
public class MissingMethodException extends
 MissingMemberException implements ISerializable
解説解説
使用例使用例

この例では、リフレクション使用して存在しないメソッド呼び出そうとしたか、または存在しないフィールドアクセスようとした場合動作示します。このアプリケーションは、MissingMethodException、MissingFieldException、および MissingMemberException をキャッチし回復します

using System;
using System.Reflection;

public class App 
{
    public static void Main()
 
    { 
        
        try 
        {
            // Attempt to call a static DoSomething method defined in
 the App class.
            // However, because the App class does not define this field,
 
            // a MissingFieldException 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 access a static AField field defined in the
 App class.
            // However, because the App class does not define this field,
 
            // a MissingFieldException is thrown.
            typeof(App).InvokeMember("AField", BindingFlags.Static | BindingFlags.SetField,
 
                null, null, new
 Object[] { 5 });
        }
        catch (MissingFieldException e) 
        {
         // Show the user that the AField field cannot be accessed.
         Console.WriteLine("Unable to access the AField field: {0}", e.Message);
        }

        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);
        }
    }       
}
// This code produces the following output.
//
// Unable to call the DoSomething method: Method 'App.DoSomething' not
 found.
// Unable to access the AField field: Field 'App.AField' not found.
// Unable to access the AnotherField field: Field 'App.AnotherField'
 not found.
using namespace System;
using namespace System::Reflection;

ref class App 
{       
};

int main()
{
    try 
    {
        // Attempt to call a static DoSomething method defined in the
 App class.
        // However, because the App class does not define this field,
 
        // a MissingFieldException 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 access a static AField field defined in the App
 class.
        // However, because the App class does not define this field,
 
        // a MissingFieldException is thrown.
        App::typeid->InvokeMember("AField", BindingFlags::Static | 
            BindingFlags::SetField, nullptr, nullptr, gcnew array<Object^>{5});
    }
    catch (MissingFieldException^ ex) 
    {
        // Show the user that the AField field cannot be accessed.
        Console::WriteLine("Unable to access the AField field: {0}", 
            ex->Message);
    }

    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.
        App::typeid->InvokeMember("AnotherField", BindingFlags::Static
 | 
            BindingFlags::GetField, nullptr, nullptr, nullptr);
    }        
    catch (MissingMemberException^ ex) 
    {
        // 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}",
 
            ex->Message);
    }
}
// This code produces the following output.
//
// Unable to call the DoSomething method: Method 'App.DoSomething' not
 found.
// Unable to access the AField field: Field 'App.AField' not found.
// Unable to access the AnotherField field: Field 'App.AnotherField'
 not found.
継承階層継承階層
System.Object
   System.Exception
     System.SystemException
       System.MemberAccessException
         System.MissingMemberException
          System.MissingMethodException
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からMissingMethodException クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からMissingMethodException クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からMissingMethodException クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「MissingMethodException クラス」の関連用語

MissingMethodException クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



MissingMethodException クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS