RealProxy.SetCOMIUnknown(IntPtr) Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Slaat een niet-beheerde proxy op van het object dat wordt vertegenwoordigd door het huidige exemplaar.
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)
Parameters
- i
-
IntPtr
nativeint
Een aanwijzer naar de IUnknown interface voor het object dat wordt vertegenwoordigd door het huidige proxy-exemplaar.
Voorbeelden
[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
Opmerkingen
Wanneer een niet-beheerde proxy probeert te communiceren met de algemene taalruntime via COM, wordt het externe object dat wordt vertegenwoordigd door de niet-beheerde proxy, door de runtime omgezet. Als het externe object wordt beheerd en zich ook in een gemeenschappelijke taalomgeving bevindt, wordt het object verzonden naar het huidige proces in plaats van ermee te communiceren via gedistribueerde COM.
Als het externe object niet is afgeleid van MarshalByRefObject, wordt het geserialiseerd en gekopieerd naar de huidige locatie. Als deze is afgeleid van MarshalByRefObject, retourneert deze een transparante proxy en slaat de externe infrastructuur de onbeheerde proxy (de IUnknown interface) in de transparante proxy op voor toekomstig gebruik.