Método Marshal.GetITypeInfoForType (Type)
Devuelve una interfaz System.Runtime.InteropServices.ComTypes.ITypeInfo de un tipo administrado.
Espacio de nombres: System.Runtime.InteropServices
Ensamblado: mscorlib (en mscorlib.dll)
Sintaxis
[SecurityCriticalAttribute]
public static IntPtr GetITypeInfoForType(
Type t
)
public:
[SecurityCriticalAttribute]
static IntPtr GetITypeInfoForType(
Type^ t
)
[<SecurityCriticalAttribute>]
static member GetITypeInfoForType :
t:Type -> nativeint
<SecurityCriticalAttribute>
Public Shared Function GetITypeInfoForType (
t As Type
) As IntPtr
Parámetros
t
Type: System.TypeTipo cuya interfaz ITypeInfo se está solicitando.
Valor devuelto
Type: System.IntPtr
Puntero a la interfaz ITypeInfo para el parámetro t.
Excepciones
Exception | Condition |
---|---|
ArgumentException | t no es un tipo visible para COM. O bien t es un tipo Windows en tiempo de ejecución. |
COMException | Se registra una biblioteca de tipos para el ensamblado que contiene el tipo, pero no se encuentra la definición de tipo. |
Comentarios
This method returns a pointer to an ITypeInfo implementation that is based on the original type. Calling an object with M:System.Runtime.InteropServices.Marshal.GetITypeInfoForType(System.Type) causes the reference count to increment on the interface pointer before the pointer is returned. Always use M:System.Runtime.InteropServices.Marshal.Release(System.IntPtr) to decrement the reference count once you have finished with the pointer. You can apply the T:System.Runtime.InteropServices.MarshalAsAttribute to replace standard interop marshaling behavior with this custom marshaler.
Ejemplos
The following example demonstrates how to retrieve a pointer to the ITypeInfo interface for a type using the M:System.Runtime.InteropServices.Marshal.GetITypeInfoForType(System.Type) method.
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
Seguridad
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Información de versión
.NET Framework
Disponible desde 1.1
Ver también
GetTypeForITypeInfo
MarshalAsAttribute
Clase Marshal
Espacio de nombres System.Runtime.InteropServices
Volver al principio