RealProxy.GetCOMIUnknown(Boolean) Metodo

Definizione

Richiede un riferimento non gestito all'oggetto rappresentato dall'istanza del proxy corrente.

public:
 virtual IntPtr GetCOMIUnknown(bool fIsMarshalled);
public virtual IntPtr GetCOMIUnknown(bool fIsMarshalled);
[System.Security.SecurityCritical]
public virtual IntPtr GetCOMIUnknown(bool fIsMarshalled);
abstract member GetCOMIUnknown : bool -> nativeint
override this.GetCOMIUnknown : bool -> nativeint
[<System.Security.SecurityCritical>]
abstract member GetCOMIUnknown : bool -> nativeint
override this.GetCOMIUnknown : bool -> nativeint
Public Overridable Function GetCOMIUnknown (fIsMarshalled As Boolean) As IntPtr

Parametri

fIsMarshalled
Boolean

true se il riferimento all'oggetto viene richiesto per il marshalling in una posizione remota; false se il riferimento all'oggetto viene richiesto per la comunicazione con oggetti non gestiti nel processo corrente tramite COM.

Valori restituiti

IntPtr

nativeint

Puntatore a un COM Callable Wrapper se il riferimento all'oggetto viene richiesto per la comunicazione con oggetti non gestiti nel processo corrente tramite COM o un puntatore a un'interfaccia COM memorizzata nella cache o appena generata IUnknown se il riferimento all'oggetto viene richiesto per il marshalling in una posizione remota.

Attributi

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

Se il proxy viene richiesto per il marshalling, viene restituita un'interfaccia IUnknown per l'oggetto rappresentato dall'istanza proxy corrente. Se un oggetto IUnknown è stato memorizzato nella cache precedentemente dal SetCOMIUnknown metodo , viene restituita tale istanza. In caso contrario, viene restituita una nuova istanza.

Se il proxy non è richiesto per il marshalling ma per la comunicazione con oggetti non gestiti nel processo corrente, viene restituito un COM Callable Wrapper (CCW), che può essere usato nel processo corrente per la comunicazione tramite COM.

Si applica a