RealProxy.SetCOMIUnknown(IntPtr) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Stores an unmanaged proxy of the object that is represented by the current instance.
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
A pointer to the IUnknown
interface for the object that is represented by the current proxy instance.
Examples
[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
Remarks
When an unmanaged proxy attempts to communicate with the common language runtime through COM, the runtime resolves the remote object that is represented by the unmanaged proxy. If the remote object is managed and also resides in a common language environment, then instead of communicating with it through distributed COM, the object is sent to the current process.
If the remote object is not derived from MarshalByRefObject, then it is serialized and copied to the current location. If it is derived from MarshalByRefObject, then it returns a transparent proxy, and the remoting infrastructure caches the unmanaged proxy (the IUnknown
interface) in the transparent proxy for future use.