Marshal.GetITypeInfoForType(Type) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
マネージド型から ITypeInfo インターフェイスを返します。
public:
static IntPtr GetITypeInfoForType(Type ^ t);
public static IntPtr GetITypeInfoForType(Type t);
[System.Security.SecurityCritical]
public static IntPtr GetITypeInfoForType(Type t);
static member GetITypeInfoForType : Type -> nativeint
[<System.Security.SecurityCritical>]
static member GetITypeInfoForType : Type -> nativeint
Public Shared Function GetITypeInfoForType (t As Type) As IntPtr
パラメーター
- t
- Type
ITypeInfo インターフェイスが要求されている型。
返品
nativeint
ITypeInfo パラメーターのt インターフェイスへのポインター。
- 属性
例外
型を含むアセンブリにタイプ ライブラリが登録されていますが、型定義が見つかりません。
例
次の例では、ITypeInfo メソッドを使用して、型のGetITypeInfoForType インターフェイスへのポインターを取得する方法を示します。
using System;
using System.Runtime.InteropServices;
class Program
{
static void Run()
{
Console.WriteLine("Calling Marshal.GetITypeInfoForType...");
// Get the ITypeInfo pointer for an Object type
IntPtr pointer = Marshal.GetITypeInfoForType(typeof(object));
Console.WriteLine("Calling Marshal.Release...");
// Always call Marshal.Release to decrement the reference count.
Marshal.Release(pointer);
}
static void Main(string[] args)
{
Run();
}
}
Imports System.Runtime.InteropServices
Module Program
Sub Run()
' Dim a pointer
Dim pointer As IntPtr
Console.WriteLine("Calling Marshal.GetIUnknownForObjectInContext...")
' Get the ITypeInfo pointer for an Object type
pointer = Marshal.GetITypeInfoForType(Type.GetType("System.Object"))
Console.WriteLine("Calling Marshal.Release...")
' Always call Marshal.Release to decrement the reference count.
Marshal.Release(pointer)
End Sub
Sub Main(ByVal args() As String)
Run()
End Sub
End Module
注釈
このメソッドは、元の型に基づく ITypeInfo 実装へのポインターを返します。
GetITypeInfoForTypeを使用してオブジェクトを呼び出すと、ポインターが返される前に、インターフェイス ポインターで参照カウントがインクリメントされます。 ポインターが終了したら、常に Marshal.Release を使用して参照カウントを減らします。
System.Runtime.InteropServices.MarshalAsAttributeを適用して、標準の相互運用マーシャリング動作をこのカスタム マーシャラーに置き換えることができます。