MissingFieldException 클래스

정의

존재하지 않는 필드를 동적으로 액세스하려고 할 때 throw되는 예외입니다.The exception that is thrown when there is an attempt to dynamically access a field that does not exist. 클래스 라이브러리에 있는 필드가 제거되거나 이름이 변경된 경우 해당 라이브러리를 참조하는 모든 어셈블리를 다시 컴파일하십시오.If a field in a class library has been removed or renamed, recompile any assemblies that reference that library.

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

예제

이 예제에서는 리플렉션을 사용 하 여 존재 하지 않는 메서드를 호출 하려고 하면 어떻게 되나요 및 존재 하지 않는 필드에 액세스 합니다.This example shows what happens if you attempt to use reflection to call a method that does not exist and access a field that does not exist. Catch 하 여 애플리케이션이 복구 된 MissingMethodException, MissingFieldException, 및 MissingMemberException합니다.The application recovers by catching the MissingMethodException, MissingFieldException, and MissingMemberException.

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 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 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.
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.
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.

설명

일반적으로 코드 클래스의 존재 하지 않는 멤버에 액세스 하려고 하는 경우 컴파일 오류가 생성 됩니다.Normally a compilation error is generated if code attempts to access a nonexistent member of a class. MissingFieldException 강력한 이름으로 참조 되지 않은 어셈블리의 이름 바꾸기 또는 삭제 된 필드에 동적으로 액세스 하려고 할 위치 하는 경우를 처리 하도록 설계 되었습니다.MissingFieldException is designed to handle cases where an attempt is made to dynamically access a renamed or deleted field of an assembly that is not referenced by its strong name. MissingFieldException 종속 어셈블리의 코드에서에서 수정 된 어셈블리에서 누락 된 필드에 액세스 하려고 할 때 throw 됩니다.The MissingFieldException is thrown when code in a dependent assembly attempts to access a missing field in an assembly that was modified.

MissingFieldException 0x80131511 값이 있는 HRESULT COR_E_MISSINGFIELD를 사용 합니다.MissingFieldException uses the HRESULT COR_E_MISSINGFIELD, that has the value 0x80131511.

인스턴스의 초기 속성 값의 목록을 MissingFieldException, 참조는 MissingFieldException 생성자입니다.For a list of initial property values for an instance of MissingFieldException, see the MissingFieldException constructors.

생성자

MissingFieldException()

MissingFieldException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the MissingFieldException class.

MissingFieldException(SerializationInfo, StreamingContext)

serialize된 데이터를 사용하여 MissingFieldException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the MissingFieldException class with serialized data.

MissingFieldException(String)

지정된 오류 메시지를 사용하여 MissingFieldException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the MissingFieldException class with a specified error message.

MissingFieldException(String, Exception)

지정된 오류 메시지와 해당 예외의 원인인 내부 예외에 대한 참조를 사용하여 MissingFieldException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the MissingFieldException class with a specified error message and a reference to the inner exception that is the cause of this exception.

MissingFieldException(String, String)

지정된 클래스 이름과 필드 이름을 사용하여 MissingFieldException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the MissingFieldException class with the specified class name and field name.

필드

ClassName

손실된 멤버의 클래스 이름을 보유합니다.Holds the class name of the missing member.

(다음에서 상속됨 MissingMemberException)
MemberName

손실된 멤버의 이름을 보유합니다.Holds the name of the missing member.

(다음에서 상속됨 MissingMemberException)
Signature

손실된 멤버의 시그니처를 보유합니다.Holds the signature of the missing member.

(다음에서 상속됨 MissingMemberException)

속성

Data

예외에 대한 사용자 정의 추가 정보를 제공하는 키/값 쌍의 컬렉션을 가져옵니다.Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(다음에서 상속됨 Exception)
HelpLink

이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다.Gets or sets a link to the help file associated with this exception.

(다음에서 상속됨 Exception)
HResult

특정 예외에 할당된 코드화된 숫자 값인 HRESULT를 가져오거나 설정합니다.Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(다음에서 상속됨 Exception)
InnerException

현재 예외를 발생시킨 Exception 인스턴스를 가져옵니다.Gets the Exception instance that caused the current exception.

(다음에서 상속됨 Exception)
Message

손실된 필드의 시그니처, 클래스 이름 및 필드 이름을 나타내는 텍스트 문자열을 가져옵니다.Gets the text string showing the signature of the missing field, the class name, and the field name. 이 속성은 읽기 전용입니다.This property is read-only.

Source

오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다.Gets or sets the name of the application or the object that causes the error.

(다음에서 상속됨 Exception)
StackTrace

호출 스택의 직접 실행 프레임에 대한 문자열 표현을 가져옵니다.Gets a string representation of the immediate frames on the call stack.

(다음에서 상속됨 Exception)
TargetSite

현재 예외를 throw하는 메서드를 가져옵니다.Gets the method that throws the current exception.

(다음에서 상속됨 Exception)

메서드

Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

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

파생 클래스에서 재정의되었을 때, 하나 이상의 후속 예외의 근본 원인이 되는 Exception을 반환합니다.When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

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

기본 해시 함수로 작동합니다.Serves as the default hash function.

(다음에서 상속됨 Object)
GetObjectData(SerializationInfo, StreamingContext)

손실된 멤버의 클래스 이름, 멤버 이름 및 시그니처와 추가 예외 정보를 사용하여 SerializationInfo 개체를 설정합니다.Sets the SerializationInfo object with the class name, the member name, the signature of the missing member, and additional exception information.

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

현재 인스턴스의 런타임 형식을 가져옵니다.Gets the runtime type of the current instance.

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

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

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

현재 예외에 대한 문자열 표현을 만들고 반환합니다.Creates and returns a string representation of the current exception.

(다음에서 상속됨 Exception)

이벤트

SerializeObjectState

예외에 대한 serialize된 데이터가 들어 있는 예외 상태 개체가 만들어지도록 예외가 serialize될 때 발생합니다.Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(다음에서 상속됨 Exception)

적용 대상

추가 정보