Reference to COM objects in Serviced Component -
04-02-2007
, 04:05 AM
Hi,
I am trying to build a COM component cache using serviced component.
My serviced class will hold reference to COM objects which will be
made available to clients.
code from the serviced class:
objCOM=CreateObject("blah")
objCOM is returned to Clients and since it is instantiated and
pooled, they dont have to wait.
Problem starts here:
Once the client is finished it calls
Marshal.ReleaseComObject(objFromServicedClass). When another client
requests for the COM object from the serviced class, it returns
objCOM. But when the client starts to work on the underlying COM
object exception "COM object that has been separated from its
underlying RCW can not be used" is thrown.
1. When we passed objCOM to client, are we just passing the RCW?
2. If two clients are working on copies of the same variable (say I
did objCOM1=objCOM) will both be working on the same underlying COM
object?
3. If I wanted to create two copies of the RCW, with two separate
copies of underlying COM object what should I be doing?
Thanks in advance |