DynamicMethod 클래스

정의

컴파일, 실행, 삭제 가능한 동적 메서드를 정의하고 나타냅니다. 삭제된 메서드는 가비지 수집에 사용할 수 있습니다.

public ref class DynamicMethod sealed : System::Reflection::MethodInfo
public sealed class DynamicMethod : System.Reflection.MethodInfo
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class DynamicMethod : System.Reflection.MethodInfo
type DynamicMethod = class
    inherit MethodInfo
[<System.Runtime.InteropServices.ComVisible(true)>]
type DynamicMethod = class
    inherit MethodInfo
Public NotInheritable Class DynamicMethod
Inherits MethodInfo
상속
특성

예제

다음 코드 예제에서는 두 개의 매개 변수를 사용하는 동적 메서드를 만듭니다. 이 예제에서는 첫 번째 매개 변수를 콘솔에 인쇄하는 간단한 함수 본문을 내보내고 두 번째 매개 변수를 메서드의 반환 값으로 사용합니다. 이 예제에서는 대리자를 만들어 메서드를 완료하고, 다른 매개 변수를 사용하여 대리자를 호출하고, 마지막으로 메서드를 사용하여 동적 메서드를 Invoke 호출합니다.

using namespace System;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
using namespace System::Globalization;

// Declare a delegate type that can be used to execute the completed
// dynamic method. 
private delegate int HelloDelegate(String^ msg, int ret);

void main()
{
    // Create an array that specifies the types of the parameters
    // of the dynamic method. This dynamic method has a String
    // parameter and an Integer parameter.
    array<Type^>^ helloArgs = { String::typeid, int::typeid };

    // Create a dynamic method with the name "Hello", a return type
    // of Integer, and two parameters whose types are specified by
    // the array helloArgs. Create the method in the module that
    // defines the String class.
    DynamicMethod^ hello = gcnew DynamicMethod("Hello", 
        int::typeid, 
        helloArgs, 
        String::typeid->Module);

    // Create an array that specifies the parameter types of the
    // overload of Console::WriteLine to be used in Hello.
    array<Type^>^ writeStringArgs = { String::typeid };
    // Get the overload of Console::WriteLine that has one
    // String parameter.
    MethodInfo^ writeString = Console::typeid->GetMethod("WriteLine", 
        writeStringArgs);

    // Get an ILGenerator and emit a body for the dynamic method,
    // using a stream size larger than the IL that will be
    // emitted.
    ILGenerator^ il = hello->GetILGenerator(256);
    // Load the first argument, which is a string, onto the stack.
    il->Emit(OpCodes::Ldarg_0);
    // Call the overload of Console::WriteLine that prints a string.
    il->EmitCall(OpCodes::Call, writeString, nullptr);
    // The Hello method returns the value of the second argument;
    // to do this, load the onto the stack and return.
    il->Emit(OpCodes::Ldarg_1);
    il->Emit(OpCodes::Ret);

    // Add parameter information to the dynamic method. (This is not
    // necessary, but can be useful for debugging.) For each parameter,
    // identified by position, supply the parameter attributes and a 
    // parameter name.
    hello->DefineParameter(1, ParameterAttributes::In, "message");
    hello->DefineParameter(2, ParameterAttributes::In, "valueToReturn");

    // Create a delegate that represents the dynamic method. This
    // action completes the method. Any further attempts to
    // change the method are ignored.
    HelloDelegate^ hi = 
        (HelloDelegate^) hello->CreateDelegate(HelloDelegate::typeid);

    // Use the delegate to execute the dynamic method.
    Console::WriteLine("\r\nUse the delegate to execute the dynamic method:");
    int retval = hi("\r\nHello, World!", 42);
    Console::WriteLine("Invoking delegate hi(\"Hello, World!\", 42) returned: " + retval);

    // Execute it again, with different arguments.
    retval = hi("\r\nHi, Mom!", 5280);
    Console::WriteLine("Invoking delegate hi(\"Hi, Mom!\", 5280) returned: " + retval);

    Console::WriteLine("\r\nUse the Invoke method to execute the dynamic method:");
    // Create an array of arguments to use with the Invoke method.
    array<Object^>^ invokeArgs = { "\r\nHello, World!", 42 };
    // Invoke the dynamic method using the arguments. This is much
    // slower than using the delegate, because you must create an
    // array to contain the arguments, and value-type arguments
    // must be boxed.
    Object^ objRet = hello->Invoke(nullptr, BindingFlags::ExactBinding, nullptr, invokeArgs, gcnew CultureInfo("en-us"));
    Console::WriteLine("hello.Invoke returned: " + objRet);

    Console::WriteLine("\r\n ----- Display information about the dynamic method -----");
    // Display MethodAttributes for the dynamic method, set when 
    // the dynamic method was created.
    Console::WriteLine("\r\nMethod Attributes: {0}", hello->Attributes);

    // Display the calling convention of the dynamic method, set when the 
    // dynamic method was created.
    Console::WriteLine("\r\nCalling convention: {0}", hello->CallingConvention);

    // Display the declaring type, which is always null for dynamic
    // methods.
    if (hello->DeclaringType == nullptr)
    {
        Console::WriteLine("\r\nDeclaringType is always null for dynamic methods.");
    }
    else
    {
        Console::WriteLine("DeclaringType: {0}", hello->DeclaringType);
    }

    // Display the default value for InitLocals.
    if (hello->InitLocals)
    {
        Console::Write("\r\nThis method contains verifiable code.");
    }
    else
    {
        Console::Write("\r\nThis method contains unverifiable code.");
    }
    Console::WriteLine(" (InitLocals = {0})", hello->InitLocals);

    // Display the module specified when the dynamic method was created.
    Console::WriteLine("\r\nModule: {0}", hello->Module);

    // Display the name specified when the dynamic method was created.
    // Note that the name can be blank.
    Console::WriteLine("\r\nName: {0}", hello->Name);

    // For dynamic methods, the reflected type is always null.
    if (hello->ReflectedType == nullptr)
    {
        Console::WriteLine("\r\nReflectedType is null.");
    }
    else
    {
        Console::WriteLine("\r\nReflectedType: {0}", hello->ReflectedType);
    }

    if (hello->ReturnParameter == nullptr)
    {
        Console::WriteLine("\r\nMethod has no return parameter.");
    }
    else
    {
        Console::WriteLine("\r\nReturn parameter: {0}", hello->ReturnParameter);
    }

    // If the method has no return type, ReturnType is System.Void.
    Console::WriteLine("\r\nReturn type: {0}", hello->ReturnType);

    // ReturnTypeCustomAttributes returns an ICustomeAttributeProvider
    // that can be used to enumerate the custom attributes of the
    // return value. At present, there is no way to set such custom
    // attributes, so the list is empty.
    if (hello->ReturnType == Void::typeid)
    {
        Console::WriteLine("The method has no return type.");
    }
    else
    {
        ICustomAttributeProvider^ caProvider = hello->ReturnTypeCustomAttributes;
        array<Object^>^ returnAttributes = caProvider->GetCustomAttributes(true);
        if (returnAttributes->Length == 0)
        {
            Console::WriteLine("\r\nThe return type has no custom attributes.");
        }
        else
        {
            Console::WriteLine("\r\nThe return type has the following custom attributes:");
            for each (Object^ attr in returnAttributes)
            {
                Console::WriteLine("\t{0}", attr->ToString());
            }
        }
    }

    Console::WriteLine("\r\nToString: {0}", hello->ToString());

    // Display parameter information.
    array<ParameterInfo^>^ parameters = hello->GetParameters();
    Console::WriteLine("\r\nParameters: name, type, ParameterAttributes");
    for each (ParameterInfo^ p in parameters)
    {
        Console::WriteLine("\t{0}, {1}, {2}", 
            p->Name, p->ParameterType, p->Attributes);
    }
}

/* This code example produces the following output:

Use the delegate to execute the dynamic method:

Hello, World!
Invoking delegate hi("Hello, World!", 42) returned: 42

Hi, Mom!
Invoking delegate hi("Hi, Mom!", 5280) returned: 5280

Use the Invoke method to execute the dynamic method:

Hello, World!
hello.Invoke returned: 42

 ----- Display information about the dynamic method -----

Method Attributes: PrivateScope, Public, Static

Calling convention: Standard

DeclaringType is always null for dynamic methods.

This method contains verifiable code. (InitLocals = True)

Module: CommonLanguageRuntimeLibrary

Name: Hello

ReflectedType is null.

Method has no return parameter.

Return type: System.Int32

The return type has no custom attributes.

ToString: Int32 Hello(System.String, Int32)

Parameters: name, type, ParameterAttributes
        message, System.String, In
        valueToReturn, System.Int32, In
 */
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Globalization;

public class Test
{
    // Declare a delegate type that can be used to execute the completed
    // dynamic method.
    private delegate int HelloDelegate(string msg, int ret);

    public static void Main()
    {
        // Create an array that specifies the types of the parameters
        // of the dynamic method. This dynamic method has a String
        // parameter and an Integer parameter.
        Type[] helloArgs = {typeof(string), typeof(int)};

        // Create a dynamic method with the name "Hello", a return type
        // of Integer, and two parameters whose types are specified by
        // the array helloArgs. Create the method in the module that
        // defines the String class.
        DynamicMethod hello = new DynamicMethod("Hello",
            typeof(int),
            helloArgs,
            typeof(string).Module);

        // Create an array that specifies the parameter types of the
        // overload of Console.WriteLine to be used in Hello.
        Type[] writeStringArgs = {typeof(string)};
        // Get the overload of Console.WriteLine that has one
        // String parameter.
        MethodInfo writeString = typeof(Console).GetMethod("WriteLine",
            writeStringArgs);

        // Get an ILGenerator and emit a body for the dynamic method,
        // using a stream size larger than the IL that will be
        // emitted.
        ILGenerator il = hello.GetILGenerator(256);
        // Load the first argument, which is a string, onto the stack.
        il.Emit(OpCodes.Ldarg_0);
        // Call the overload of Console.WriteLine that prints a string.
        il.EmitCall(OpCodes.Call, writeString, null);
        // The Hello method returns the value of the second argument;
        // to do this, load the onto the stack and return.
        il.Emit(OpCodes.Ldarg_1);
        il.Emit(OpCodes.Ret);

        // Add parameter information to the dynamic method. (This is not
        // necessary, but can be useful for debugging.) For each parameter,
        // identified by position, supply the parameter attributes and a
        // parameter name.
        hello.DefineParameter(1, ParameterAttributes.In, "message");
        hello.DefineParameter(2, ParameterAttributes.In, "valueToReturn");

        // Create a delegate that represents the dynamic method. This
        // action completes the method. Any further attempts to
        // change the method are ignored.
        HelloDelegate hi =
            (HelloDelegate) hello.CreateDelegate(typeof(HelloDelegate));

        // Use the delegate to execute the dynamic method.
        Console.WriteLine("\r\nUse the delegate to execute the dynamic method:");
        int retval = hi("\r\nHello, World!", 42);
        Console.WriteLine("Invoking delegate hi(\"Hello, World!\", 42) returned: " + retval);

        // Execute it again, with different arguments.
        retval = hi("\r\nHi, Mom!", 5280);
        Console.WriteLine("Invoking delegate hi(\"Hi, Mom!\", 5280) returned: " + retval);

        Console.WriteLine("\r\nUse the Invoke method to execute the dynamic method:");
        // Create an array of arguments to use with the Invoke method.
        object[] invokeArgs = {"\r\nHello, World!", 42};
        // Invoke the dynamic method using the arguments. This is much
        // slower than using the delegate, because you must create an
        // array to contain the arguments, and value-type arguments
        // must be boxed.
        object objRet = hello.Invoke(null, BindingFlags.ExactBinding, null, invokeArgs, new CultureInfo("en-us"));
        Console.WriteLine("hello.Invoke returned: " + objRet);

        Console.WriteLine("\r\n ----- Display information about the dynamic method -----");
        // Display MethodAttributes for the dynamic method, set when
        // the dynamic method was created.
        Console.WriteLine("\r\nMethod Attributes: {0}", hello.Attributes);

        // Display the calling convention of the dynamic method, set when the
        // dynamic method was created.
        Console.WriteLine("\r\nCalling convention: {0}", hello.CallingConvention);

        // Display the declaring type, which is always null for dynamic
        // methods.
        if (hello.DeclaringType == null)
        {
            Console.WriteLine("\r\nDeclaringType is always null for dynamic methods.");
        }
        else
        {
            Console.WriteLine("DeclaringType: {0}", hello.DeclaringType);
        }

        // Display the default value for InitLocals.
        if (hello.InitLocals)
        {
            Console.Write("\r\nThis method contains verifiable code.");
        }
        else
        {
            Console.Write("\r\nThis method contains unverifiable code.");
        }
        Console.WriteLine(" (InitLocals = {0})", hello.InitLocals);

        // Display the module specified when the dynamic method was created.
        Console.WriteLine("\r\nModule: {0}", hello.Module);

        // Display the name specified when the dynamic method was created.
        // Note that the name can be blank.
        Console.WriteLine("\r\nName: {0}", hello.Name);

        // For dynamic methods, the reflected type is always null.
        if (hello.ReflectedType == null)
        {
            Console.WriteLine("\r\nReflectedType is null.");
        }
        else
        {
            Console.WriteLine("\r\nReflectedType: {0}", hello.ReflectedType);
        }

        if (hello.ReturnParameter == null)
        {
            Console.WriteLine("\r\nMethod has no return parameter.");
        }
        else
        {
            Console.WriteLine("\r\nReturn parameter: {0}", hello.ReturnParameter);
        }

        // If the method has no return type, ReturnType is System.Void.
        Console.WriteLine("\r\nReturn type: {0}", hello.ReturnType);

        // ReturnTypeCustomAttributes returns an ICustomeAttributeProvider
        // that can be used to enumerate the custom attributes of the
        // return value. At present, there is no way to set such custom
        // attributes, so the list is empty.
        if (hello.ReturnType == typeof(void))
        {
            Console.WriteLine("The method has no return type.");
        }
        else
        {
            ICustomAttributeProvider caProvider = hello.ReturnTypeCustomAttributes;
            object[] returnAttributes = caProvider.GetCustomAttributes(true);
            if (returnAttributes.Length == 0)
            {
                Console.WriteLine("\r\nThe return type has no custom attributes.");
            }
            else
            {
                Console.WriteLine("\r\nThe return type has the following custom attributes:");
                foreach( object attr in returnAttributes )
                {
                    Console.WriteLine("\t{0}", attr.ToString());
                }
            }
        }

        Console.WriteLine("\r\nToString: {0}", hello.ToString());

        // Display parameter information.
        ParameterInfo[] parameters = hello.GetParameters();
        Console.WriteLine("\r\nParameters: name, type, ParameterAttributes");
        foreach( ParameterInfo p in parameters )
        {
            Console.WriteLine("\t{0}, {1}, {2}",
                p.Name, p.ParameterType, p.Attributes);
        }
    }
}

/* This code example produces the following output:

Use the delegate to execute the dynamic method:

Hello, World!
Invoking delegate hi("Hello, World!", 42) returned: 42

Hi, Mom!
Invoking delegate hi("Hi, Mom!", 5280) returned: 5280

Use the Invoke method to execute the dynamic method:

Hello, World!
hello.Invoke returned: 42

 ----- Display information about the dynamic method -----

Method Attributes: PrivateScope, Public, Static

Calling convention: Standard

DeclaringType is always null for dynamic methods.

This method contains verifiable code. (InitLocals = True)

Module: CommonLanguageRuntimeLibrary

Name: Hello

ReflectedType is null.

Method has no return parameter.

Return type: System.Int32

The return type has no custom attributes.

ToString: Int32 Hello(System.String, Int32)

Parameters: name, type, ParameterAttributes
        message, System.String, In
        valueToReturn, System.Int32, In
 */
Imports System.Reflection
Imports System.Reflection.Emit
Imports System.Globalization

Public Class Test
    ' Declare a delegate type that can be used to execute the completed
    ' dynamic method. 
    Private Delegate Function HelloDelegate(ByVal msg As String, _
        ByVal ret As Integer) As Integer

    Public Shared Sub Main()
        ' Create an array that specifies the types of the parameters
        ' of the dynamic method. This dynamic method has a String
        ' parameter and an Integer parameter.
        Dim helloArgs() As Type = {GetType(String), GetType(Integer)}

        ' Create a dynamic method with the name "Hello", a return type
        ' of Integer, and two parameters whose types are specified by
        ' the array helloArgs. Create the method in the module that
        ' defines the String class.
        Dim hello As New DynamicMethod("Hello", _
            GetType(Integer), _
            helloArgs, _
            GetType(String).Module)

        ' Create an array that specifies the parameter types of the
        ' overload of Console.WriteLine to be used in Hello.
        Dim writeStringArgs() As Type = {GetType(String)}
        ' Get the overload of Console.WriteLine that has one
        ' String parameter.
        Dim writeString As MethodInfo = GetType(Console). _
            GetMethod("WriteLine", writeStringArgs) 

        ' Get an ILGenerator and emit a body for the dynamic method,
        ' using a stream size larger than the IL that will be
        ' emitted.
        Dim il As ILGenerator = hello.GetILGenerator(256)
        ' Load the first argument, which is a string, onto the stack.
        il.Emit(OpCodes.Ldarg_0)
        ' Call the overload of Console.WriteLine that prints a string.
        il.EmitCall(OpCodes.Call, writeString, Nothing)
        ' The Hello method returns the value of the second argument;
        ' to do this, load the onto the stack and return.
        il.Emit(OpCodes.Ldarg_1)
        il.Emit(OpCodes.Ret)

        ' Add parameter information to the dynamic method. (This is not
        ' necessary, but can be useful for debugging.) For each parameter,
        ' identified by position, supply the parameter attributes and a 
        ' parameter name.
        hello.DefineParameter(1, ParameterAttributes.In, "message")
        hello.DefineParameter(2, ParameterAttributes.In, "valueToReturn")

        ' Create a delegate that represents the dynamic method. This
        ' action completes the method. Any further attempts to
        ' change the method are ignored.
    Dim hi As HelloDelegate = _
            CType(hello.CreateDelegate(GetType(HelloDelegate)), HelloDelegate)

        ' Use the delegate to execute the dynamic method.
        Console.WriteLine(vbCrLf & "Use the delegate to execute the dynamic method:")
        Dim retval As Integer = hi(vbCrLf & "Hello, World!", 42)
        Console.WriteLine("Invoking delegate hi(""Hello, World!"", 42) returned: " _
            & retval & ".")

        ' Execute it again, with different arguments.
        retval = hi(vbCrLf & "Hi, Mom!", 5280)
        Console.WriteLine("Invoking delegate hi(""Hi, Mom!"", 5280) returned: " _
            & retval & ".")

        Console.WriteLine(vbCrLf & "Use the Invoke method to execute the dynamic method:")
        ' Create an array of arguments to use with the Invoke method.
        Dim invokeArgs() As Object = {vbCrLf & "Hello, World!", 42}
        ' Invoke the dynamic method using the arguments. This is much
        ' slower than using the delegate, because you must create an
        ' array to contain the arguments, and value-type arguments
        ' must be boxed.
        Dim objRet As Object = hello.Invoke(Nothing, _
            BindingFlags.ExactBinding, Nothing, invokeArgs, _
            New CultureInfo("en-us"))
        Console.WriteLine("hello.Invoke returned: {0}", objRet)

        Console.WriteLine(vbCrLf & _
            " ----- Display information about the dynamic method -----")
        ' Display MethodAttributes for the dynamic method, set when 
        ' the dynamic method was created.
        Console.WriteLine(vbCrLf & "Method Attributes: {0}", _
            hello.Attributes)

        ' Display the calling convention of the dynamic method, set when the 
        ' dynamic method was created.
        Console.WriteLine(vbCrLf & "Calling convention: {0}", _ 
            hello.CallingConvention)

        ' Display the declaring type, which is always Nothing for dynamic
        ' methods.
        If hello.DeclaringType Is Nothing Then
            Console.WriteLine(vbCrLf & "DeclaringType is always Nothing for dynamic methods.")
        Else
            Console.WriteLine("DeclaringType: {0}", hello.DeclaringType)
        End If

        ' Display the default value for InitLocals.
        If hello.InitLocals Then
            Console.Write(vbCrLf & "This method contains verifiable code.")
        Else
            Console.Write(vbCrLf & "This method contains unverifiable code.")
        End If
        Console.WriteLine(" (InitLocals = {0})", hello.InitLocals)

        ' Display the module specified when the dynamic method was created.
        Console.WriteLine(vbCrLf & "Module: {0}", hello.Module)

        ' Display the name specified when the dynamic method was created.
        ' Note that the name can be blank.
        Console.WriteLine(vbCrLf & "Name: {0}", hello.Name)

        ' For dynamic methods, the reflected type is always Nothing.
        If hello.ReflectedType Is Nothing Then
            Console.WriteLine(vbCrLf & "ReflectedType is Nothing.")
        Else
            Console.WriteLine(vbCrLf & "ReflectedType: {0}", _
                hello.ReflectedType)
        End If

        If hello.ReturnParameter Is Nothing Then
            Console.WriteLine(vbCrLf & "Method has no return parameter.")
        Else
            Console.WriteLine(vbCrLf & "Return parameter: {0}", _
                hello.ReturnParameter)
        End If

        ' If the method has no return type, ReturnType is System.Void.
        Console.WriteLine(vbCrLf & "Return type: {0}", hello.ReturnType)           

        ' ReturnTypeCustomAttributes returns an ICustomeAttributeProvider
        ' that can be used to enumerate the custom attributes of the
        ' return value. At present, there is no way to set such custom
        ' attributes, so the list is empty.
        If hello.ReturnType Is GetType(System.Void) Then
            Console.WriteLine("The method has no return type.")
        Else
            Dim caProvider As ICustomAttributeProvider = _
                hello.ReturnTypeCustomAttributes
            Dim returnAttributes() As Object = _
                caProvider.GetCustomAttributes(True)
            If returnAttributes.Length = 0 Then
                Console.WriteLine(vbCrLf _
                    & "The return type has no custom attributes.")
            Else
                Console.WriteLine(vbCrLf _
                    & "The return type has the following custom attributes:")
                For Each attr As Object In returnAttributes
                    Console.WriteLine(vbTab & attr.ToString())
                Next attr
            End If
        End If

        Console.WriteLine(vbCrLf & "ToString: " & hello.ToString())

        ' Display parameter information.
        Dim parameters() As ParameterInfo = hello.GetParameters()
        Console.WriteLine(vbCrLf & "Parameters: name, type, ParameterAttributes")
        For Each p As ParameterInfo In parameters
            Console.WriteLine(vbTab & "{0}, {1}, {2}", _ 
                p.Name, p.ParameterType, p.Attributes)
        Next p
    End Sub
End Class

' This code example produces the following output:
'
'Use the delegate to execute the dynamic method:
'
'Hello, World!
'Invoking delegate hi("Hello, World!", 42) returned: 42.
'
'Hi, Mom!
'Invoking delegate hi("Hi, Mom!", 5280) returned: 5280.
'
'Use the Invoke method to execute the dynamic method:
'
'Hello, World!
'hello.Invoke returned: 42
'
' ----- Display information about the dynamic method -----
'
'Method Attributes: PrivateScope, Public, Static
'
'Calling convention: Standard
'
'DeclaringType is always Nothing for dynamic methods.
'
'This method contains verifiable code. (InitLocals = True)
'
'Module: CommonLanguageRuntimeLibrary
'
'Name: Hello
'
'ReflectedType is Nothing.
'
'Method has no return parameter.
'
'Return type: System.Int32
'
'The return type has no custom attributes.
'
'ToString: Int32 Hello(System.String, Int32)
'
'Parameters: name, type, ParameterAttributes
'        message, System.String, In
'        valueToReturn, System.Int32, In

설명

클래스를 DynamicMethod 사용하여 메서드를 포함할 동적 어셈블리 및 동적 형식을 생성하지 않고도 런타임에 메서드를 생성하고 실행할 수 있습니다. JIT(Just-In-Time) 컴파일러에서 만든 실행 코드는 개체가 DynamicMethod 회수될 때 회수됩니다. 동적 메서드는 소량의 코드를 생성하고 실행하는 가장 효율적인 방법입니다.

동적 메서드는 익명으로 호스트되거나 모듈 또는 형식과 논리적으로 연결될 수 있습니다.

  • 동적 메서드가 익명으로 호스트되는 경우 시스템 제공 어셈블리에 있으므로 다른 코드와 격리됩니다. 기본적으로 공용이 아닌 데이터에는 액세스할 수 없습니다. 익명으로 호스트되는 동적 메서드는 플래그를 사용하여 부여된 경우 JIT 컴파일러의 표시 여부 검사를 건너뛰는 기능이 제한될 ReflectionPermissionReflectionPermissionFlag.RestrictedMemberAccess 수 있습니다. 동적 메서드에서 비공용 멤버에 액세스하는 어셈블리의 신뢰 수준은 동적 메서드를 내보낸 호출 스택의 신뢰 수준 또는 하위 집합과 같아야 합니다. 익명으로 호스트되는 동적 메서드에 대한 자세한 내용은 연습: 부분 신뢰 시나리오에서 코드 내보내기를 참조하세요.

  • 동적 메서드가 지정한 모듈과 연결된 경우 동적 메서드는 해당 모듈에 효과적으로 전역화됩니다. 모듈의 모든 형식과 형식의 모든 internal (Friend Visual Basic의 경우) 멤버에 액세스할 수 있습니다. 코드를 포함하는 호출 스택에서 플래그에 대한 ReflectionPermission 수요를 충족할 수 있는 경우 모듈을 만들었는지 여부에 관계없이 동적 메서드를 모듈과 RestrictedMemberAccess 연결할 수 있습니다. 플래그가 ReflectionPermissionFlag.MemberAccess 권한 부여에 포함된 경우 동적 메서드는 JIT 컴파일러의 표시 여부 검사를 건너뛰고 모듈 또는 어셈블리의 다른 모듈에 선언된 모든 형식의 프라이빗 데이터에 액세스할 수 있습니다.

    참고

    동적 메서드가 연결된 모듈을 지정하는 경우 해당 모듈은 익명 호스팅에 사용되는 시스템 제공 어셈블리에 있으면 안 됩니다.

  • 동적 메서드가 지정한 형식과 연결된 경우 액세스 수준에 관계없이 형식의 모든 멤버에 액세스할 수 있습니다. 또한 JIT 표시 유형 검사를 건너뛸 수 있습니다. 이렇게 하면 동적 메서드가 동일한 모듈 또는 어셈블리의 다른 모듈에 선언된 다른 형식의 프라이빗 데이터에 액세스할 수 있습니다. 동적 메서드를 모든 형식과 연결할 수 있지만 및 플래그를 모두 RestrictedMemberAccessMemberAccess 사용하여 코드를 부여 ReflectionPermission 해야 합니다.

다음 표에서는 플래그가 부여되었는지 여부에 ReflectionPermission 따라 JIT 표시 여부 검사를 포함 또는 사용하지 않고 익명으로 호스트된 동적 메서드에 액세스할 수 있는 형식과 멤버를 RestrictedMemberAccess 보여줍니다.

RestrictedMemberAccess 사용 안 함 RestrictedMemberAccess 사용
JIT 표시 유형 검사를 건너뛰지 않고 모든 어셈블리에서 공용 형식의 공용 멤버입니다. 모든 어셈블리에서 공용 형식의 공용 멤버입니다.
JIT 표시 유형 검사를 건너뛰고 제한 사항 모든 어셈블리에서 공용 형식의 공용 멤버입니다. 신뢰 수준이 동적 메서드를 내보낸 어셈블리의 신뢰 수준과 같거나 작은 어셈블리에서만 모든 형식의 모든 멤버입니다.

참고

.NET Framework 2.0에서는 코드 생성이 기본적으로 권한 있는 작업이 아니기 때문에 보안 요구를 실행하지 않고 부분 신뢰 시나리오에서 코드를 내보냅니다. 즉, 생성된 코드에 코드를 내보내는 어셈블리보다 많은 권한이 없습니다. 따라서 코드를 내보내는 라이브러리가 보안상 투명할 수 있으며 ReflectionEmit를 어설션할 필요가 없으므로 보안 라이브러리 작성 작업이 간소화됩니다. 이 기능을 사용하려면 애플리케이션이 .NET Framework 3.5 이상을 대상으로 해야 합니다.

다음 표에서는 모듈 또는 모듈의 형식과 연결된 동적 메서드에 액세스할 수 있는 형식 및 멤버를 보여 있습니다.

모듈과 연결됨 형식과 연결됨
JIT 표시 유형 검사를 건너뛰지 않고 모듈의 공용, 내부 및 프라이빗 형식의 공용 및 내부 멤버입니다.

모든 어셈블리에서 공용 형식의 공용 멤버입니다.
연결된 형식의 모든 멤버입니다. 모듈에 있는 다른 모든 형식의 공용 및 내부 멤버입니다.

모든 어셈블리에서 공용 형식의 공용 멤버입니다.
JIT 표시 여부 검사 건너뛰기 모든 어셈블리에 있는 모든 형식의 모든 멤버입니다. 모든 어셈블리에 있는 모든 형식의 모든 멤버입니다.

모듈과 연결된 동적 메서드에는 해당 모듈의 권한이 있습니다. 형식과 연결된 동적 메서드에는 해당 형식을 포함하는 모듈의 권한이 있습니다.

동적 메서드 및 해당 매개 변수의 이름을 지정할 필요는 없지만 디버깅에 도움이 되는 이름을 지정할 수 있습니다. 사용자 지정 특성은 동적 메서드 또는 해당 매개 변수에서 지원되지 않습니다.

동적 메서드는 static 메서드(SharedVisual Basic의 메서드)이지만 .NET Framework 2.0에 도입된 대리자 바인딩에 대한 완화된 규칙을 사용하면 동적 메서드를 개체에 바인딩할 수 있으므로 해당 대리자 인스턴스를 사용하여 호출할 때 인스턴스 메서드처럼 작동합니다. 이를 보여 주는 예제는 메서드 오버로드에 CreateDelegate(Type, Object) 대해 제공됩니다.

참고

.NET Framework 2.0에서 동적 메서드는 기호 정보, 즉 지역 변수 이름 및 줄 번호 매핑을 지원하지 않습니다. 이 제한 사항은 이후 버전에서 제거될 수 있습니다. 개발 중에 를 사용하여 AssemblyBuilder 생성된 MSIL(Microsoft 중간 언어) 디버깅을 간소화한 다음, 두 경우 모두 호출이 동일하기 때문에 ILGenerator 최종 배포 중에 동적 메서드로 전환할 수 있습니다.

확인

다음 목록에서는 동적 메서드에 확인할 수 없는 코드를 포함할 수 있는 조건을 요약합니다. (예를 들어 동적 메서드는 해당 InitLocals 속성이 로 설정된 false경우 확인되지 않습니다.)

  • 보안에 중요한 어셈블리와 연결된 동적 메서드도 보안에 중요하며 확인을 건너뛸 수 있습니다. 예를 들어, 데스크톱 애플리케이션으로 실행 되는 보안 특성 없이 어셈블리는 런타임에서 보안에 중요로 처리 됩니다. 동적 메서드를 어셈블리와 연결하면 동적 메서드에 확인할 수 없는 코드가 포함될 수 있습니다.

  • 확인되지 않는 코드를 포함하는 동적 메서드가 수준 1 투명도가 있는 어셈블리와 연결된 경우 JIT(Just-In-Time) 컴파일러는 보안 요구를 주입합니다. 동적 메서드가 완전히 신뢰할 수 있는 코드에 의해 실행되는 경우에만 요청이 성공합니다. 보안 투명 코드, 수준 1을 참조하세요.

  • 확인되지 않는 코드를 포함하는 동적 메서드가 수준 2 투명도(예: mscorlib.dll)가 있는 어셈블리와 연결된 경우 보안 요구를 하는 대신 예외(JIT 컴파일러에서 삽입)를 throw합니다. 보안 투명 코드, 수준 2를 참조하세요.

  • 확인되지 않는 코드를 포함하는 익명으로 호스트된 동적 메서드는 항상 예외를 throw합니다. 완전히 신뢰할 수 있는 코드에서 만들고 실행하더라도 확인을 건너뛸 수 없습니다.

확인되지 않는 코드에 대해 throw되는 예외는 동적 메서드가 호출되는 방식에 따라 달라집니다. 메서드에서 CreateDelegate 반환된 대리자를 사용하여 동적 메서드를 호출하면 이 VerificationException throw됩니다. 메서드를 사용하여 동적 메서드를 InvokeTargetInvocationException 호출하는 경우 는 내부 VerificationException를 사용하여 throw됩니다.

생성자

DynamicMethod(String, MethodAttributes, CallingConventions, Type, Type[], Module, Boolean)

모듈 전체에 적용되는 동적 메서드를 만들어 메서드 이름, 특성, 호출 규칙, 반환 형식, 매개 변수 형식, 모듈을 지정하고, 동적 메서드의 MSIL(Microsoft Intermediate Language)이 액세스하는 형식과 멤버에 대해 JIT(just-in-time) 표시 유형 확인을 건너뛸지 여부를 지정합니다.

DynamicMethod(String, MethodAttributes, CallingConventions, Type, Type[], Type, Boolean)

동적 메서드를 만들고, 메서드 이름, 특성, 호출 규칙, 반환 형식, 매개 변수 형식, 동적 메서드가 논리적으로 연결되는 형식, 동적 메서드의 MSIL(Microsoft Intermediate Language)이 액세스하는 형식과 멤버에 대해 JIT(just-in-time) 표시 유형 확인을 건너뛸지 여부를 지정합니다.

DynamicMethod(String, Type, Type[])

메서드 이름, 반환 형식 및 매개 변수 형식을 지정하여 익명으로 호스트되는 동적 메서드를 초기화합니다.

DynamicMethod(String, Type, Type[], Boolean)

메서드 이름, 반환 형식, 매개 변수 형식, 그리고 동적 메서드의 MSIL(Microsoft Intermediate Language)에서 액세스하는 형식 및 멤버에 대해 JIT(적시) 가시성 검사를 건너뛰어야 하는지 여부를 지정하는 익명으로 호스팅된 동적 메서드를 초기화합니다.

DynamicMethod(String, Type, Type[], Module)

메서드 이름, 반환 형식, 매개 변수 형식 및 모듈을 지정하여 모듈 전체에서 사용되는 동적 메서드를 만듭니다.

DynamicMethod(String, Type, Type[], Module, Boolean)

모듈 전체에 적용되는 동적 메서드를 만들어 메서드 이름, 반환 형식, 매개 변수 형식, 모듈을 지정하고, 동적 메서드의 MSIL(Microsoft Intermediate Language)이 액세스하는 형식과 멤버에 대해 JIT(just-in-time) 표시 유형 확인을 건너뛸지 여부를 지정합니다.

DynamicMethod(String, Type, Type[], Type)

메서드 이름, 반환 형식, 매개 변수 형식 및 동적 메서드가 논리적으로 연결된 형식을 지정하여 동적 메서드를 만듭니다.

DynamicMethod(String, Type, Type[], Type, Boolean)

동적 메서드를 만들고, 메서드 이름, 반환 형식, 매개 변수 형식, 동적 메서드가 논리적으로 연결되는 형식, 동적 메서드의 MSIL(Microsoft Intermediate Language)이 액세스하는 형식과 멤버에 대해 JIT(just-in-time) 표시 유형 확인을 건너뛸지 여부를 지정합니다.

속성

Attributes

동적 메서드를 만들 때 지정된 특성을 가져옵니다.

CallingConvention

동적 메서드를 만들 때 지정된 호출 규칙을 가져옵니다.

ContainsGenericParameters

제네릭 메서드에 할당되지 않은 제네릭 형식 매개 변수가 포함되어 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodInfo)
CustomAttributes

이 멤버의 사용자 지정 특성을 포함하는 컬렉션을 가져옵니다.

(다음에서 상속됨 MemberInfo)
DeclaringType

동적 메서드에 대해 항상 null 인 메서드를 선언하는 형식을 가져옵니다.

InitLocals

메서드의 로컬 변수가 0으로 초기화되었는지 여부를 나타내는 값을 가져오거나 설정합니다.

IsAbstract

이 메서드가 추상 메서드인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
IsAssembly

Assembly에서 이 메서드나 생성자의 잠재적 표시 유형을 설명하는지 여부를 나타내는 값을 가져옵니다. 즉, 이 메서드나 생성자는 같은 어셈블리의 다른 형식에만 표시되고 어셈블리 외부의 파생 형식에는 표시되지 않습니다.

(다음에서 상속됨 MethodBase)
IsCollectible

MemberInfo 개체가 수집 가능한 AssemblyLoadContext에 보관된 어셈블리의 일부인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MemberInfo)
IsConstructedGenericMethod

컴파일, 실행, 삭제 가능한 동적 메서드를 정의하고 나타냅니다. 삭제된 메서드는 가비지 수집에 사용할 수 있습니다.

(다음에서 상속됨 MethodBase)
IsConstructor

메서드가 생성자인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
IsFamily

Family에서 이 메서드나 생성자의 표시 유형을 설명하는지 여부를 나타내는 값을 가져옵니다. 즉, 이 메서드나 생성자는 해당 클래스 및 파생 클래스에만 표시됩니다.

(다음에서 상속됨 MethodBase)
IsFamilyAndAssembly

FamANDAssem에서 이 메서드나 생성자의 표시 유형을 설명하는지 여부를 나타내는 값을 가져옵니다. 즉, 이 메서드나 생성자는 같은 어셈블리에 있는 경우에만 파생 클래스에서 호출할 수 있습니다.

(다음에서 상속됨 MethodBase)
IsFamilyOrAssembly

FamORAssem에서 이 메서드나 생성자의 잠재적 표시 유형을 설명하는지 여부를 나타내는 값을 가져옵니다. 즉, 이 메서드나 생성자는 파생 클래스(있는 경우) 및 같은 어셈블리의 클래스에서 호출할 수 있습니다.

(다음에서 상속됨 MethodBase)
IsFinal

이 메서드가 final인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
IsGenericMethod

현재 메서드가 제네릭 메서드인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodInfo)
IsGenericMethodDefinition

현재 MethodInfo가 제네릭 메서드 정의를 나타내는지 여부를 표시하는 값을 가져옵니다.

(다음에서 상속됨 MethodInfo)
IsHideBySig

동일한 시그니처가 있는 동일한 종류의 멤버만을 파생 클래스에서 숨길 수 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
IsPrivate

이 멤버가 프라이빗인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
IsPublic

이 메서드가 public 메서드인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
IsSecurityCritical

현재 동적 메서드가 보안에 중요한 형식이거나 보안 안전에 중요한 형식이어서 중요한 작업을 수행할 수 있는지 여부를 나타내는 값을 가져옵니다.

IsSecurityCritical

현재 메서드나 생성자가 현재 신뢰 수준에서 보안에 중요한 형식이거나 보안 안전에 중요한 형식이어서 중요한 작업을 수행할 수 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
IsSecuritySafeCritical

현재 동적 메서드가 현재 신뢰 수준에서 보안 안전에 중요한 형식인지, 즉 중요한 작업을 수행할 수 있고 투명 코드로 액세스할 수 있는지 여부를 나타내는 값을 가져옵니다.

IsSecuritySafeCritical

현재 메서드나 생성자가 현재 신뢰 수준에서 보안 안전에 중요한 형식인지 즉, 중요한 작업을 수행할 수 있고 투명 코드로 액세스할 수 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
IsSecurityTransparent

현재 동적 메서드가 현재 신뢰 수준에서 투명하여 중요한 작업을 수행할 수 없는지 여부를 나타내는 값을 가져옵니다.

IsSecurityTransparent

현재 메서드나 생성자가 현재 신뢰 수준에서 투명하여 중요한 작업을 수행할 수 없는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
IsSpecialName

이 메서드의 이름이 특수한지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
IsStatic

메서드가 static인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
IsVirtual

메서드가 virtual인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 MethodBase)
MemberType

이 멤버가 메서드임을 나타내는 MemberTypes 값을 가져옵니다.

(다음에서 상속됨 MethodInfo)
MetadataToken

메타데이터 요소를 식별하는 값을 가져옵니다.

(다음에서 상속됨 MemberInfo)
MethodHandle

동적 메서드에는 지원되지 않습니다.

MethodHandle

메서드의 내부 메타데이터 표현에 대한 핸들을 가져옵니다.

(다음에서 상속됨 MethodBase)
MethodImplementationFlags

컴파일, 실행, 삭제 가능한 동적 메서드를 정의하고 나타냅니다. 삭제된 메서드는 가비지 수집에 사용할 수 있습니다.

MethodImplementationFlags

메서드 구현의 특성을 지정하는 MethodImplAttributes 플래그를 가져옵니다.

(다음에서 상속됨 MethodBase)
Module

동적 메서드가 논리적으로 연결된 모듈을 가져옵니다.

Module

현재 MemberInfo가 나타내는 멤버를 선언하는 형식이 정의된 모듈을 가져옵니다.

(다음에서 상속됨 MemberInfo)
Name

동적 메서드의 이름입니다.

ReflectedType

메서드를 얻기 위해 리플렉션에서 사용된 클래스를 가져옵니다.

ReflectedType

MemberInfo의 이 인스턴스를 가져오는 데 사용된 클래스 개체를 가져옵니다.

(다음에서 상속됨 MemberInfo)
ReturnParameter

동적 메서드의 반환 매개 변수를 가져옵니다.

ReturnType

동적 메서드의 반환 값 형식을 가져옵니다.

ReturnTypeCustomAttributes

동적 메서드에 대한 반환 형식의 사용자 지정 특성을 가져옵니다.

ReturnTypeCustomAttributes

반환 형식에 대한 사용자 지정 특성을 가져옵니다.

(다음에서 상속됨 MethodInfo)

메서드

CreateDelegate(Type)

동적 메서드를 완료하고 실행하는 데 사용할 수 있는 대리자를 만듭니다.

CreateDelegate(Type, Object)

동적 메서드를 완료하고 대리자 형식과 대리자가 바인딩되는 개체를 지정하여 해당 메서드를 실행하는 데 사용할 수 있는 대리자를 만듭니다.

CreateDelegate<T>()

이 메서드에서 T 형식의 대리자를 만듭니다.

(다음에서 상속됨 MethodInfo)
CreateDelegate<T>(Object)

이 메서드에서 지정된 대상을 사용하여 T 형식의 대리자를 만듭니다.

(다음에서 상속됨 MethodInfo)
DefineParameter(Int32, ParameterAttributes, String)

동적 메서드의 매개 변수를 정의합니다.

Equals(Object)

이 인스턴스가 지정된 개체와 같은지를 나타내는 값을 반환합니다.

(다음에서 상속됨 MethodInfo)
GetBaseDefinition()

메서드에 대한 기본 구현을 반환합니다.

GetBaseDefinition()

파생 클래스에서 재정의되는 경우 이 인스턴스가 나타내는 메서드가 처음 선언된 직접 또는 간접 기본 클래스의 메서드에 대해 MethodInfo 개체를 반환합니다.

(다음에서 상속됨 MethodInfo)
GetCustomAttributes(Boolean)

이 메서드에 대해 정의된 모든 사용자 지정 특성을 반환합니다.

GetCustomAttributes(Boolean)

파생 클래스에서 재정의되는 경우 이 멤버에 적용된 모든 사용자 지정 특성의 배열을 반환합니다.

(다음에서 상속됨 MemberInfo)
GetCustomAttributes(Type, Boolean)

메서드에 적용된 지정된 형식의 사용자 지정 특성을 반환합니다.

GetCustomAttributes(Type, Boolean)

파생된 클래스에서 재정의하는 경우 이 멤버에 적용되고 Type으로 식별되는 사용자 지정 특성의 배열을 반환합니다.

(다음에서 상속됨 MemberInfo)
GetCustomAttributesData()

대상 멤버에 적용된 특성에 대한 데이터를 나타내는 CustomAttributeData 개체의 목록을 반환합니다.

(다음에서 상속됨 MemberInfo)
GetDynamicILInfo()

메타데이터 토큰, 범위 및 MSIL(Microsoft Intermediate Language) 스트림에서 메서드 본문을 생성하는 데 사용할 수 있는 DynamicILInfo 개체입니다.

GetGenericArguments()

제네릭 메서드의 형식 인수나 제네릭 메서드 정의의 형식 매개 변수를 나타내는 Type 개체의 배열을 반환합니다.

(다음에서 상속됨 MethodInfo)
GetGenericMethodDefinition()

현재 메서드를 생성하는 데 사용할 수 있는 제네릭 메서드 정의를 나타내는 MethodInfo 개체를 반환합니다.

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

이 인스턴스의 해시 코드를 반환합니다.

(다음에서 상속됨 MethodInfo)
GetILGenerator()

64바이트의 기본 MSIL(Microsoft Intermediate Language) 스트림 크기를 사용하는 메서드에 대한 MSIL 생성기를 반환합니다.

GetILGenerator(Int32)

지정된 된 MSIL 스트림 크기를 사용하는 메서드에 대한 MSIL(Microsoft Intermediate Language) 생성기를 반환합니다.

GetMethodBody()

파생 클래스에서 재정의된 경우, 현재 메서드의 MSIL 스트림, 지역 변수 및 예외에 액세스할 수 있도록 하는 MethodBody 개체를 가져옵니다.

(다음에서 상속됨 MethodBase)
GetMethodImplementationFlags()

메서드에 대한 구현 플래그를 반환합니다.

GetMethodImplementationFlags()

파생 클래스에서 재정의할 때 MethodImplAttributes 플래그를 반환합니다.

(다음에서 상속됨 MethodBase)
GetParameters()

동적 메서드의 매개 변수를 반환합니다.

GetType()

메서드의 특성을 검색하고 메서드 메타데이터에 대한 액세스를 제공합니다.

(다음에서 상속됨 MethodInfo)
HasSameMetadataDefinitionAs(MemberInfo)

컴파일, 실행, 삭제 가능한 동적 메서드를 정의하고 나타냅니다. 삭제된 메서드는 가비지 수집에 사용할 수 있습니다.

(다음에서 상속됨 MemberInfo)
Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)

지정된 문화권 정보를 사용하고 지정된 바인더의 제약 조건에 따라, 지정된 매개 변수를 사용하여 동적 메서드를 호출합니다.

Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)

파생 클래스에서 재정의된 경우, 지정된 매개 변수를 사용하여 리플렉션된 메서드나 생성자를 호출합니다.

(다음에서 상속됨 MethodBase)
Invoke(Object, Object[])

지정된 매개 변수를 사용하여 현재 인스턴스로 나타낸 메서드 또는 생성자를 호출합니다.

(다음에서 상속됨 MethodInfo)
IsDefined(Type, Boolean)

지정된 사용자 지정 특성 유형이 정의되었는지 여부를 나타냅니다.

IsDefined(Type, Boolean)

파생 클래스에서 재정의되는 경우 지정된 형식 또는 파생 형식의 특성이 하나 이상 이 멤버에 적용되는지 여부를 나타냅니다.

(다음에서 상속됨 MemberInfo)
MakeGenericMethod(Type[])

현재 제네릭 메서드 정의의 형식 매개 변수를 형식 배열의 요소로 대체하고, 결과로 생성된 메서드를 나타내는 MethodInfo 개체를 반환합니다.

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

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

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

문자열로 표현된 메서드의 서명을 반환합니다.

명시적 인터페이스 구현

_MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 MemberInfo)
_MemberInfo.GetType()

Type 클래스를 나타내는 MemberInfo 개체를 가져옵니다.

(다음에서 상속됨 MemberInfo)
_MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 MemberInfo)
_MemberInfo.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 MemberInfo)
_MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 MemberInfo)
_MethodBase.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 MethodBase)
_MethodBase.GetType()

이 멤버에 대한 설명은 GetType()를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 MethodBase)
_MethodBase.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 MethodBase)
_MethodBase.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 MethodBase)
_MethodBase.IsAbstract

이 멤버에 대한 설명은 IsAbstract를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsAssembly

이 멤버에 대한 설명은 IsAssembly를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsConstructor

이 멤버에 대한 설명은 IsConstructor를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsFamily

이 멤버에 대한 설명은 IsFamily를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsFamilyAndAssembly

이 멤버에 대한 설명은 IsFamilyAndAssembly를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsFamilyOrAssembly

이 멤버에 대한 설명은 IsFamilyOrAssembly를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsFinal

이 멤버에 대한 설명은 IsFinal를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsHideBySig

이 멤버에 대한 설명은 IsHideBySig를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsPrivate

이 멤버에 대한 설명은 IsPrivate를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsPublic

이 멤버에 대한 설명은 IsPublic를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsSpecialName

이 멤버에 대한 설명은 IsSpecialName를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsStatic

이 멤버에 대한 설명은 IsStatic를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodBase.IsVirtual

이 멤버에 대한 설명은 IsVirtual를 참조하세요.

(다음에서 상속됨 MethodBase)
_MethodInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 MethodInfo)
_MethodInfo.GetType()

COM에서 GetType() 메서드에 대한 액세스를 제공합니다.

(다음에서 상속됨 MethodInfo)
_MethodInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 MethodInfo)
_MethodInfo.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 MethodInfo)
_MethodInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 MethodInfo)
ICustomAttributeProvider.GetCustomAttributes(Boolean)

명명된 특성을 제외하고 이 멤버에 정의된 모든 사용자 지정 특성의 배열을 반환하거나 사용자 지정 특성이 없는 경우 빈 배열을 반환합니다.

(다음에서 상속됨 MemberInfo)
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)

형식으로 식별되는 이 멤버에 정의된 사용자 지정 특성의 배열을 반환하거나 해당 형식의 사용자 지정 특성이 없는 경우 빈 배열을 반환합니다.

(다음에서 상속됨 MemberInfo)
ICustomAttributeProvider.IsDefined(Type, Boolean)

하나 이상의 attributeType 인스턴스가 이 멤버에 대해 정의되는지 여부를 나타냅니다.

(다음에서 상속됨 MemberInfo)

확장 메서드

GetCustomAttribute(MemberInfo, Type)

지정된 멤버에 적용된 지정된 형식의 사용자 지정 특성을 검색합니다.

GetCustomAttribute(MemberInfo, Type, Boolean)

지정된 형식의 사용자 지정 특성이 지정된 멤버에 적용되는 컬렉션을 검색하거나 선택적으로 해당 멤버의 상위 항목을 검사합니다.

GetCustomAttribute<T>(MemberInfo)

지정된 멤버에 적용된 지정된 형식의 사용자 지정 특성을 검색합니다.

GetCustomAttribute<T>(MemberInfo, Boolean)

지정된 형식의 사용자 지정 특성이 지정된 멤버에 적용되는 컬렉션을 검색하거나 선택적으로 해당 멤버의 상위 항목을 검사합니다.

GetCustomAttributes(MemberInfo)

지정된 멤버에 적용된 사용자 지정 특성 컬렉션을 검색합니다.

GetCustomAttributes(MemberInfo, Boolean)

사용자 지정 특성이 지정된 멤버에 적용되는 컬렉션을 검색하거나 선택적으로 해당 멤버의 상위 항목을 검사합니다.

GetCustomAttributes(MemberInfo, Type)

지정된 멤버에 적용된 지정된 형식의 사용자 지정 특성 컬렉션을 검색합니다.

GetCustomAttributes(MemberInfo, Type, Boolean)

지정된 형식의 사용자 지정 특성이 지정된 멤버에 적용되는 컬렉션을 검색하거나 선택적으로 해당 멤버의 상위 항목을 검사합니다.

GetCustomAttributes<T>(MemberInfo)

지정된 멤버에 적용된 지정된 형식의 사용자 지정 특성 컬렉션을 검색합니다.

GetCustomAttributes<T>(MemberInfo, Boolean)

지정된 형식의 사용자 지정 특성이 지정된 멤버에 적용되는 컬렉션을 검색하거나 선택적으로 해당 멤버의 상위 항목을 검사합니다.

IsDefined(MemberInfo, Type)

지정된 형식의 사용자 지정 특성이 지정된 멤버에 적용되었는지 여부를 나타냅니다.

IsDefined(MemberInfo, Type, Boolean)

지정된 형식의 사용자 지정 특성이 지정된 멤버에 적용되었는지, 또는 선택적으로 상위 항목에 적용되었는지 여부를 결정합니다.

GetMetadataToken(MemberInfo)

사용 가능한 경우 지정된 멤버의 메타데이터 토큰을 가져옵니다.

HasMetadataToken(MemberInfo)

지정된 멤버에 대해 메타데이터 토큰을 사용할 수 있는지를 나타내는 값을 반환합니다.

GetBaseDefinition(MethodInfo)

컴파일, 실행, 삭제 가능한 동적 메서드를 정의하고 나타냅니다. 삭제된 메서드는 가비지 수집에 사용할 수 있습니다.

GetRuntimeBaseDefinition(MethodInfo)

메서드가 처음으로 선언된 직접 또는 간접 기본 클래스에서 지정된 메서드를 표현하는 개체를 검색합니다.

적용 대상

추가 정보