英語で読む

次の方法で共有


MethodBuilder.SetMarshal(UnmanagedMarshal) メソッド

定義

注意事項

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

このメソッドの戻り値の型のマーシャリング情報を設定します。

C#
public void SetMarshal (System.Reflection.Emit.UnmanagedMarshal unmanagedMarshal);
C#
[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);

パラメーター

unmanagedMarshal
UnmanagedMarshal

このメソッドの戻り値の型のマーシャリング情報。

属性

例外

含まれている型は、CreateType() を使用して以前に作成されています。

- または -

現在のメソッドでは、IsGenericMethod プロパティは true ですが、IsGenericMethodDefinition プロパティは false です。

次のコード サンプルは、メソッド呼び出しの結果を SetMarshal 別の型としてマーシャリングするメソッドのコンテキストでの使用方法を示しています。

C#

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);

適用対象

製品 バージョン (廃止)
.NET Framework 1.1 (2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1)