MethodBuilder.SetMarshal メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MethodBuilder.SetMarshal メソッドの意味・解説 

MethodBuilder.SetMarshal メソッド

メモ : このメソッドは、互換性のために残されています。

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

名前空間: System.Reflection.Emit
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<ObsoleteAttribute("An alternate API is available: Emit the
 MarshalAs custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")>
 _
Public Sub SetMarshal ( _
    unmanagedMarshal As UnmanagedMarshal _
)
Dim instance As MethodBuilder
Dim unmanagedMarshal As UnmanagedMarshal

instance.SetMarshal(unmanagedMarshal)
[ObsoleteAttribute("An alternate API is available: Emit the MarshalAs custom
 attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")]
 
public void SetMarshal (
    UnmanagedMarshal unmanagedMarshal
)
[ObsoleteAttribute(L"An alternate API is available: Emit the MarshalAs custom
 attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")]
 
public:
void SetMarshal (
    UnmanagedMarshal^ unmanagedMarshal
)
/** @attribute ObsoleteAttribute("An alternate API is available: Emit the MarshalAs
 custom attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")
 */ 
public void SetMarshal (
    UnmanagedMarshal unmanagedMarshal
)
ObsoleteAttribute("An alternate API is available: Emit the MarshalAs custom
 attribute instead. http://go.microsoft.com/fwlink/?linkid=14202")
 
public function SetMarshal (
    unmanagedMarshal : UnmanagedMarshal
)

パラメータ

unmanagedMarshal

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

例外例外
例外種類条件

InvalidOperationException

外側の型が CreateType を使用して作成されています。

または

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

使用例使用例

SetMarshal メソッド使用してメソッド呼び出し結果別の型としてマーシャリングする方法については、次のコード例参照してください

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)

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

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, 
    int.class.ToType(), new
 Type[] { String.class.ToType() });

// 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 クラス
MethodBuilder メンバ
System.Reflection.Emit 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

MethodBuilder.SetMarshal メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



MethodBuilder.SetMarshal メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS