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)

適用対象