This documentation is archived and is not being maintained.

RealProxy.GetCOMIUnknown Method

Requests an unmanaged reference to the object represented by the current proxy instance.

[Visual Basic]
Public Overridable Function GetCOMIUnknown( _
   ByVal fIsMarshalled As Boolean _
) As IntPtr
[C#]
public virtual IntPtr GetCOMIUnknown(
 bool fIsMarshalled
);
[C++]
public: virtual IntPtr GetCOMIUnknown(
 bool fIsMarshalled
);
[JScript]
public function GetCOMIUnknown(
   fIsMarshalled : Boolean
) : IntPtr;

Parameters

fIsMarshalled
true if the object reference is requested for marshaling to a remote location; false if the object reference is requested for communication with unmanaged objects in the current process through COM.

Return Value

A pointer to a COM Callable Wrapper if the object reference is requested for communication with unmanaged objects in the current process through COM, or a pointer to a cached or newly generated IUnknown COM interface if the object reference is requested for marshaling to a remote location.

Remarks

If the proxy is requested for marshaling, then an IUnknown interface for the object represented by the current proxy instance is returned. If an IUnknown was previously cached by the SetCOMIUnknown method, then that instance is returned; otherwise, a new instance is returned.

If the proxy is requested not for marshaling but for communication with unmanaged objects in the current process, then a COM Callable Wrapper (CCW), which can be used in the current process for communication through COM, is returned.

Example

[Visual Basic] 
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

[C#] 
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;
}

[C++] 
public:
   IntPtr SupportsInterface(Guid* /*myGuid*/)
   {
      Console::WriteLine(S"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;
   }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

RealProxy Class | RealProxy Members | System.Runtime.Remoting.Proxies Namespace

Show: