Share via


RealProxy.SetCOMIUnknown(IntPtr) Método

Definición

Almacena un proxy no administrado del objeto representado por la instancia actual.

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

Puntero a la interfaz IUnknown para el objeto representado por la instancia actual del proxy.

Ejemplos

[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

Comentarios

Cuando un proxy no administrado intenta comunicarse con Common Language Runtime a través de COM, el tiempo de ejecución resuelve el objeto remoto representado por el proxy no administrado. Si el objeto remoto se administra y también reside en un entorno de lenguaje común, en lugar de comunicarse con él a través de COM distribuido, el objeto se envía al proceso actual.

Si el objeto remoto no se deriva de MarshalByRefObject, se serializa y se copia en la ubicación actual. Si se deriva de MarshalByRefObject, devuelve un proxy transparente y la infraestructura de comunicación remota almacena en caché el proxy no administrado (la IUnknown interfaz) en el proxy transparente para su uso futuro.

Se aplica a