I have a reference to a COM object, and would like to pass that reference on to another process. So, I'd need some way to serialize information about this reference that would allow me to restore it again in the other process.
Is there any way to do this for COM objects of any arbitrary type?
I'm don't know too much about COM; from what I understand, there may be Monikers for some types of objects (for example, COM references such as Excel.Workbook might be restored via their .FullName property which seems to be used as the moniker), but so far I haven't found if something like this is possible for any kind of COM object
Here's one way:
CoMarshalInterface
to marshal the interface to a stream. Convert bytes written to stream to a base-64 string (or any other encoding). Pass the encoded string to your client.Server side:
Client side: