Método Marshal.GetComInterfaceForObjectInContext (Object, Type)
Dica
The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.
Retorna um ponteiro de interface que representa a interface especificada para um objeto, se o chamador estiver no mesmo contexto que o objeto.
Namespace: System.Runtime.InteropServices
Assembly: mscorlib (em mscorlib.dll)
Sintaxe
[SecurityCriticalAttribute]
public static IntPtr GetComInterfaceForObjectInContext(
object o,
Type t
)
public:
[SecurityCriticalAttribute]
static IntPtr GetComInterfaceForObjectInContext(
Object^ o,
Type^ t
)
[<SecurityCriticalAttribute>]
static member GetComInterfaceForObjectInContext :
o:Object *
t:Type -> nativeint
<SecurityCriticalAttribute>
Public Shared Function GetComInterfaceForObjectInContext (
o As Object,
t As Type
) As IntPtr
Parâmetros
o
Type: System.ObjectO objeto que fornece a interface.
t
Type: System.TypeO tipo de interface solicitado.
Valor Retornado
Type: System.IntPtr
O ponteiro de interface especificado por t que representa a interface para o objeto especificado ou null, se o chamador não estiver no mesmo contexto de objeto.
Exceções
Exception | Condition |
---|---|
ArgumentException | t não é uma interface. -ou- O tipo não é visível para COM. |
InvalidCastException | o não dá suporte à interface solicitada. |
ArgumentNullException | o é null. -ou- t é null. |
Comentários
Esse método é o mesmo que GetComInterfaceForObject exceto que ela retorna null se o chamador não está no mesmo contexto de objeto. É particularmente útil se você tiver um método não gerenciado que espera deve passar um ponteiro de interface.
Segurança
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Informações de Versão
.NET Framework
Disponível desde 2.0
Confira Também
GetComInterfaceForObject
ComImportAttribute
Release
UCOMIConnectionPointContainer
GetIDispatchForObject
Classe Marshal
Namespace System.Runtime.InteropServices
Retornar ao início