MethodBuilder.SetImplementationFlags(MethodImplAttributes) 메서드

정의

이 메서드에 대한 구현 플래그를 설정합니다.

public:
 void SetImplementationFlags(System::Reflection::MethodImplAttributes attributes);
public void SetImplementationFlags (System.Reflection.MethodImplAttributes attributes);
member this.SetImplementationFlags : System.Reflection.MethodImplAttributes -> unit
Public Sub SetImplementationFlags (attributes As MethodImplAttributes)

매개 변수

attributes
MethodImplAttributes

설정할 구현 플래그입니다.

예외

포함하는 형식은 이전에 CreateType()을 사용하여 만든 것입니다.

또는

현재 메서드에 대해 IsGenericMethod 속성은 true이지만 IsGenericMethodDefinition 속성은 false입니다.

예제

아래 코드 샘플에서는 메서드 본문에서 MSIL의 SetImplementationFlags 구현을 설명하는 메서드의 컨텍스트 사용을 보여 줍니다.

array<Type^>^ temp0 = { int::typeid, int::typeid };
MethodBuilder^ myMthdBuilder = myTypeBuilder->DefineMethod( "MyMethod",
                               MethodAttributes::Public,
                               CallingConventions::HasThis,
                               int::typeid,
                               temp0 );

// Specifies that the dynamic method declared above has a an MSIL implementation,
// is managed, synchronized (single-threaded) through the body, and that it
// cannot be inlined.

myMthdBuilder->SetImplementationFlags( (MethodImplAttributes)(
                                        MethodImplAttributes::IL |
                                        MethodImplAttributes::Managed |
                                        MethodImplAttributes::Synchronized |
                                        MethodImplAttributes::NoInlining) );

// Create an ILGenerator for the MethodBuilder and emit MSIL here ...
MethodBuilder myMthdBuilder = myTypeBuilder.DefineMethod("MyMethod",
                    MethodAttributes.Public,
                    CallingConventions.HasThis,
                    typeof(int),
                    new Type[] { typeof(int),
                             typeof(int) });	

// Specifies that the dynamic method declared above has a an MSIL implementation,
    // is managed, synchronized (single-threaded) through the body, and that it
// cannot be inlined.

myMthdBuilder.SetImplementationFlags(MethodImplAttributes.IL |
                     MethodImplAttributes.Managed |
                     MethodImplAttributes.Synchronized |
                     MethodImplAttributes.NoInlining);

// Create an ILGenerator for the MethodBuilder and emit MSIL here ...
Dim myMthdBuilder As MethodBuilder = myTypeBuilder.DefineMethod("MyMethod", _
                 MethodAttributes.Public, _
                 CallingConventions.HasThis, _
                 GetType(Integer), _
                 New Type() {GetType(Integer), GetType(Integer)})

' Specifies that the dynamic method declared above has a an MSIL implementation,
' is managed, synchronized (single-threaded) through the body, and that it 
' cannot be inlined.

myMthdBuilder.SetImplementationFlags((MethodImplAttributes.IL Or _
                  MethodImplAttributes.Managed Or _
                  MethodImplAttributes.Synchronized Or _
                  MethodImplAttributes.NoInlining))

' Create an ILGenerator for the MethodBuilder and emit MSIL here ...

설명

메서드와 SetImplementationFlags 함께 메서드를 SetCustomAttribute 사용하는 경우 잠재적인 상호 작용에 유의해야 합니다. 예를 들어 메서드를 SetCustomAttribute 사용하여 특성을 추가하면 DllImportAttribute 플래그도 설정됩니다 MethodImplAttributes.PreserveSig . 이후에 메서드를 SetImplementationFlags 호출하면 플래그를 PreserveSig 덮어씁니다. 이를 방지하는 방법에는 다음 두 가지가 있습니다.

적용 대상