RealProxy.SetCOMIUnknown(IntPtr) Metodo

Definizione

Archivia un proxy non gestito dell'oggetto rappresentato dall'istanza corrente.

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)

Parametri

i
IntPtr

nativeint

Puntatore all'interfaccia IUnknown per l'oggetto rappresentato dall'istanza del proxy corrente.

Esempio

[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

Commenti

Quando un proxy non gestito tenta di comunicare con Common Language Runtime tramite COM, il runtime risolve l'oggetto remoto rappresentato dal proxy non gestito. Se l'oggetto remoto è gestito e risiede anche in un ambiente common language, anziché comunicare con esso tramite COM distribuito, l'oggetto viene inviato al processo corrente.

Se l'oggetto remoto non è derivato da MarshalByRefObject, viene serializzato e copiato nella posizione corrente. Se è derivato da MarshalByRefObject, restituisce un proxy trasparente e l'infrastruttura remota memorizza nella cache il proxy non gestito (l'interfaccia IUnknown ) nel proxy trasparente per un uso futuro.

Si applica a