MethodBuilder.SetMarshal(UnmanagedMarshal) 메서드

정의

주의

An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202

이 메서드의 반환 형식에 대한 마샬링 정보를 설정합니다.

public:
 void SetMarshal(System::Reflection::Emit::UnmanagedMarshal ^ unmanagedMarshal);
public void SetMarshal (System.Reflection.Emit.UnmanagedMarshal unmanagedMarshal);
[System.Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public void SetMarshal (System.Reflection.Emit.UnmanagedMarshal unmanagedMarshal);
member this.SetMarshal : System.Reflection.Emit.UnmanagedMarshal -> unit
[<System.Obsolete("An alternate API is available: Emit the MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")>]
member this.SetMarshal : System.Reflection.Emit.UnmanagedMarshal -> unit
Public Sub SetMarshal (unmanagedMarshal As UnmanagedMarshal)

매개 변수

unmanagedMarshal
UnmanagedMarshal

이 메서드의 반환 형식에 대한 마샬링 정보입니다.

특성

예외

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

또는

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

예제

아래 코드 샘플에서는 메서드 호출의 SetMarshal 결과를 다른 형식으로 마샬링하는 메서드의 컨텍스트 사용법을 보여 줍니다.

array<Type^>^ temp0 = { String::typeid };
MethodBuilder^ myMethod = myDynamicType->DefineMethod( "MyMethodReturnsMarshal",
                          MethodAttributes::Public,
                          UInt32::typeid,
                          temp0 );

// We want the return value of our dynamic method to be marshalled as
// an 64-bit (8-Byte) signed integer, instead of the default 32-bit
// unsigned int as specified above. The UnmanagedMarshal class can perform
// the type conversion.

UnmanagedMarshal^ marshalMeAsI8 = UnmanagedMarshal::DefineUnmanagedMarshal(
                                  System::Runtime::InteropServices::UnmanagedType::I8 );

myMethod->SetMarshal( marshalMeAsI8 );

MethodBuilder myMethod = myDynamicType.DefineMethod("MyMethodReturnsMarshal",
                    MethodAttributes.Public,
                    typeof(uint),
                    new Type[] { typeof(string) });

// We want the return value of our dynamic method to be marshalled as
// an 64-bit (8-byte) signed integer, instead of the default 32-bit
// unsigned int as specified above. The UnmanagedMarshal class can perform
// the type conversion.

UnmanagedMarshal marshalMeAsI8 = UnmanagedMarshal.DefineUnmanagedMarshal(
                     System.Runtime.InteropServices.UnmanagedType.I8);	

myMethod.SetMarshal(marshalMeAsI8);
Dim myMethod As MethodBuilder = myDynamicType.DefineMethod("MyMethodReturnsMarshal", _
              MethodAttributes.Public, GetType(System.UInt32), _
              New Type() {GetType(String)}) 

' We want the return value of our dynamic method to be marshalled as 
' an 64-bit (8-byte) signed integer, instead of the default 32-bit
' unsigned int as specified above. The UnmanagedMarshal class can perform
' the type conversion.

Dim marshalMeAsI8 As UnmanagedMarshal = UnmanagedMarshal.DefineUnmanagedMarshal( _
                    System.Runtime.InteropServices.UnmanagedType.I8)

myMethod.SetMarshal(marshalMeAsI8)

적용 대상