4.1 Using the IManagedObject Interface

A CLR instance uses the IManagedObject interface in the following manner.

  1. A CLR instance starts up and generates a UUID to uniquely identify itself. It later creates a process subdivision and creates a unique value to identify the process subdivision.

  2. A COM object enters the CLR, and the CLR then calls the IUnknown::QueryInterface method to determine whether the object implements IManagedObject. The object returns S_OK and returns a pointer to an IManagedObject interface pointer.

  3. The CLR then calls the IManagedObject::GetObjectIdentity method and matches the pBSTRGUID against its UUID and, if they match, compares the AppDomainID to the identifier of the current process subdivision. If they match, the CLR converts pCCW to the underlying CLR-managed object. If they do not match, it calls the IManagedObject::GetSerializedBuffer method and uses the binary-formatted version of the object converted to a string to create a copy of the object that resides in another CLR (which could be a completely different implementation). The caller on the client CLR is then able to interpret the deserialized opaque object reference. For more information about how to create the binary-formatted string representation of an object, see [MS-NRBF] section 2.3.