Marshal.GetITypeInfoForType(Type) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Devolve uma ITypeInfo interface de um tipo gerido.
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
Parâmetros
- t
- Type
O tipo cuja ITypeInfo interface está a ser solicitada.
Devoluções
nativeint
Um apontador para a ITypeInfo interface do t parâmetro.
- Atributos
Exceções
Uma biblioteca de tipos é registada para o assembly que contém o tipo, mas a definição do tipo não pode ser encontrada.
Exemplos
O exemplo seguinte demonstra como recuperar um ponteiro para a ITypeInfo interface de um tipo usando o GetITypeInfoForType método.
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
Observações
Este método devolve um ponteiro para uma ITypeInfo implementação baseada no tipo original. Chamar um objeto com GetITypeInfoForType faz com que a contagem de referências aumente no ponteiro da interface antes de este ser devolvido. Usa Marshal.Release sempre para diminuir a contagem de referências depois de terminares com o apontador. Pode aplicar o System.Runtime.InteropServices.MarshalAsAttribute para substituir o comportamento padrão de marshaling interop com este marshaler personalizado.