RealProxy.SetCOMIUnknown(IntPtr) Método

Definição

Armazena um proxy não gerenciado do objeto que é representado pela instância atual.

public:
 virtual void SetCOMIUnknown(IntPtr i);
public virtual void SetCOMIUnknown (IntPtr i);
abstract member SetCOMIUnknown : nativeint -> unit
override this.SetCOMIUnknown : nativeint -> unit
Public Overridable Sub SetCOMIUnknown (i As IntPtr)

Parâmetros

i
IntPtr

nativeint

Um ponteiro para a interface IUnknown do objeto que é representado pela instância de proxy atual.

Exemplos

[SecurityPermission(SecurityAction::LinkDemand, Flags = SecurityPermissionFlag::Infrastructure)]
IntPtr SupportsInterface( Guid * /*myGuid*/ )
{
   Console::WriteLine( "SupportsInterface method called" );
   
   // Object reference is requested for communication with unmanaged objects
   // in the current process through COM.
   IntPtr myIntPtr = this->GetCOMIUnknown( false );
   
   // Stores an unmanaged proxy of the object.
   this->SetCOMIUnknown( myIntPtr );
   
   // return COM Runtime Wrapper pointer.
   return myIntPtr;
}
public override IntPtr SupportsInterface(ref Guid myGuid)
{
    Console.WriteLine("SupportsInterface method called");
    // Object reference is requested for communication with unmanaged objects
    // in the current process through COM.
    IntPtr myIntPtr = this.GetCOMIUnknown(false);
    // Stores an unmanaged proxy of the object.
    this.SetCOMIUnknown(myIntPtr);
    // return COM Runtime Wrapper pointer.
    return myIntPtr;
}
<SecurityPermission(SecurityAction.LinkDemand, Flags := SecurityPermissionFlag.Infrastructure)> _
Public Overrides Function SupportsInterface(ByRef myGuid As Guid) As IntPtr
   Console.WriteLine("SupportsInterface method called")
   ' Object reference is requested for communication with unmanaged objects
   ' in the current process through COM.
   Dim myIntPtr As IntPtr = Me.GetCOMIUnknown(False)
   ' Stores an unmanaged proxy of the object.
   Me.SetCOMIUnknown(myIntPtr)
   ' return COM Runtime Wrapper pointer.
   Return myIntPtr
End Function 'SupportsInterface

Comentários

Quando um proxy não gerenciado tenta se comunicar com o Common Language Runtime por meio de COM, o runtime resolve o objeto remoto representado pelo proxy não gerenciado. Se o objeto remoto for gerenciado e também residir em um ambiente de linguagem comum, em vez de se comunicar com ele por meio de COM distribuído, o objeto será enviado para o processo atual.

Se o objeto remoto não for derivado de MarshalByRefObject, ele será serializado e copiado para o local atual. Se for derivado de MarshalByRefObject, ele retornará um proxy transparente e a infraestrutura de comunicação remota armazenará em cache o proxy não gerenciado (a IUnknown interface) no proxy transparente para uso futuro.

Aplica-se a