Marshal.GetITypeInfoForType(Type) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Restituisce un'interfaccia ITypeInfo da un tipo gestito.
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
Parametri
- t
- Type
Tipo di cui è richiesta l'interfaccia ITypeInfo
.
Restituisce
-
IntPtr
nativeint
Puntatore all'interfaccia ITypeInfo
per il parametro t
.
- Attributi
Eccezioni
È stata registrata una libreria dei tipi per l'assembly che contiene il tipo, ma non è possibile trovare la definizione del tipo.
Esempio
Nell'esempio seguente viene illustrato come recuperare un puntatore all'interfaccia ITypeInfo
per un tipo usando il GetITypeInfoForType metodo .
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
Commenti
Questo metodo restituisce un puntatore a un'implementazione ITypeInfo
basata sul tipo originale. La chiamata a un oggetto con GetITypeInfoForType fa sì che il conteggio dei riferimenti venga incrementato sul puntatore dell'interfaccia prima che venga restituito il puntatore. Usare Marshal.Release sempre per decrementare il conteggio dei riferimenti al termine dell'operazione con il puntatore. È possibile applicare per sostituire il System.Runtime.InteropServices.MarshalAsAttribute comportamento di marshalling di interoperabilità standard con questo gestore di marshalling personalizzato.