This documentation is archived and is not being maintained.

RealProxy.SetCOMIUnknown Method

Stores an unmanaged proxy of the object that is represented by the current instance.

Namespace:  System.Runtime.Remoting.Proxies
Assembly:  mscorlib (in mscorlib.dll)

public virtual void SetCOMIUnknown(
	IntPtr i
)

Parameters

i
Type: System.IntPtr

A pointer to the IUnknown interface for the object that is represented by the current proxy instance.

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.

[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
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;
}
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;
   }

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: