MissingMethodException 클래스

정의

존재하지 않는 메서드에 동적으로 액세스하려고 할 때 throw되는 예외입니다.

public ref class MissingMethodException : MissingMemberException
public class MissingMethodException : MissingMemberException
[System.Serializable]
public class MissingMethodException : MissingMemberException
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class MissingMethodException : MissingMemberException
type MissingMethodException = class
    inherit MissingMemberException
type MissingMethodException = class
    inherit MissingMemberException
    interface ISerializable
[<System.Serializable>]
type MissingMethodException = class
    inherit MissingMemberException
    interface ISerializable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type MissingMethodException = class
    inherit MissingMemberException
    interface ISerializable
Public Class MissingMethodException
Inherits MissingMemberException
상속
상속
특성
구현

예제

이 예제에서는 리플렉션을 사용하여 존재하지 않는 메서드를 호출하고 존재하지 않는 필드에 액세스하려고 하면 어떻게 되는지 보여줍니다. 애플리케이션은 < a0/> 및 .를 catch하여 복구됩니다.

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 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 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 example 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.
open System
open System.Reflection

type App = class end

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 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, [| box 5 |])
    |> ignore
with :? MissingFieldException as e ->
    // Show the user that the AField field cannot be accessed.
    printfn $"Unable to access the AField field: {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)
    |> ignore
with :? MissingMemberException as 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.
    printfn $"Unable to access the AnotherField field: {e.Message}"
// This code example 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.
Imports System.Reflection

Public Class App
    Public Shared Sub Main() 
        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
        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.
            GetType(App).InvokeMember("AField", BindingFlags.Static Or BindingFlags.SetField, _
                                       Nothing, Nothing, New [Object]() {5})
        Catch e As MissingFieldException
            ' Show the user that the AField field cannot be accessed.
            Console.WriteLine("Unable to access the AField field: {0}", e.Message)
        End Try
        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.
            GetType(App).InvokeMember("AnotherField", BindingFlags.Static Or BindingFlags.GetField, _
                                       Nothing, Nothing, Nothing)
        Catch e As MissingMemberException
            ' 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)
        End Try
    End Sub 
End Class 
' This code example 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.

설명

일반적으로 코드가 클래스의 존재하지 않는 메서드에 액세스하려고 하면 컴파일 오류가 생성됩니다. MissingMethodException 는 강력한 이름으로 참조되지 않는 어셈블리의 이름이 변경되거나 삭제된 메서드에 동적으로 액세스하려고 시도하는 경우를 처리하도록 설계되었습니다. MissingMethodException 는 종속 어셈블리의 코드가 수정된 어셈블리에서 누락된 메서드에 액세스하려고 할 때 throw됩니다.

MissingMethodException 는 값이 0x80131513 HRESULT COR_E_MISSINGMETHOD 사용합니다.

MissingMethodException인스턴스의 초기 속성 값 목록은 MissingMethodException 생성자를 참조하세요.

정적으로 참조된 메서드가 로드되는 정확한 타이밍은 지정되지 않습니다. 누락된 메서드를 참조하는 메서드가 실행을 시작하기 전에 이 예외가 throw될 수 있습니다.

생성자

Name Description
MissingMethodException()

MissingMethodException 클래스의 새 인스턴스를 초기화합니다.

MissingMethodException(SerializationInfo, StreamingContext)
사용되지 않음.

직렬화된 데이터를 사용하여 클래스의 새 인스턴스를 MissingMethodException 초기화합니다.

MissingMethodException(String, Exception)

지정된 오류 메시지와 이 예외의 MissingMethodException 원인인 내부 예외에 대한 참조를 사용하여 클래스의 새 인스턴스를 초기화합니다.

MissingMethodException(String, String)

지정된 클래스 이름 및 메서드 이름을 사용하여 클래스의 MissingMethodException 새 인스턴스를 초기화합니다.

MissingMethodException(String)

지정된 오류 메시지를 사용하여 클래스의 MissingMethodException 새 인스턴스를 초기화합니다.

필드

Name Description
ClassName

누락된 멤버의 클래스 이름을 보유합니다.

(다음에서 상속됨 MissingMemberException)
MemberName

누락된 멤버의 이름을 보유합니다.

(다음에서 상속됨 MissingMemberException)
Signature

누락된 멤버의 서명을 보유합니다.

(다음에서 상속됨 MissingMemberException)

속성

Name Description
Data

예외에 대한 추가 사용자 정의 정보를 제공하는 키/값 쌍의 컬렉션을 가져옵니다.

(다음에서 상속됨 Exception)
HelpLink

이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
HResult

특정 예외에 할당된 코딩된 숫자 값인 HRESULT를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
InnerException

현재 예외를 Exception 발생시킨 인스턴스를 가져옵니다.

(다음에서 상속됨 Exception)
Message

클래스 이름, 메서드 이름 및 누락된 메서드의 서명을 보여 주는 텍스트 문자열을 가져옵니다. 이 속성은 읽기 전용입니다.

Source

오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
StackTrace

호출 스택에서 직접 실행 프레임의 문자열 표현을 가져옵니다.

(다음에서 상속됨 Exception)
TargetSite

현재 예외를 throw하는 메서드를 가져옵니다.

(다음에서 상속됨 Exception)

메서드

Name Description
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetBaseException()

파생 클래스에서 재정의되는 경우 하나 이상의 후속 예외의 근본 원인인 값을 반환 Exception 합니다.

(다음에서 상속됨 Exception)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetObjectData(SerializationInfo, StreamingContext)
사용되지 않음.

SerializationInfo 클래스 이름, 멤버 이름, 누락된 멤버의 서명 및 추가 예외 정보를 사용하여 개체를 설정합니다.

(다음에서 상속됨 MissingMemberException)
GetType()

현재 인스턴스의 런타임 형식을 가져옵니다.

(다음에서 상속됨 Exception)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 예외의 문자열 표현을 만들고 반환합니다.

(다음에서 상속됨 Exception)

이벤트

Name Description
SerializeObjectState
사용되지 않음.

예외에 대한 직렬화된 데이터를 포함하는 예외 상태 개체를 만들기 위해 예외가 serialize될 때 발생합니다.

(다음에서 상속됨 Exception)

적용 대상

추가 정보