tags:

views:

216

answers:

0

I have a ServicedComponent COM+ class running in a server application. It uses JIT and pooling. I want to keep track of all of the existing instances in a singleton list and call a method UpdateDisplay on them every once in a while.

I have each ServicedComponent-derived object register itself by inserting a reference to itself into a singleton list the first time the client calls its main method. I have a Timer object whose callback then walks the list to call the method on the registered objects. Everything is properly protected by locks.

The problem is that when the callback tries to call a method on the object, I get ObjectDisposedException. The stack trace shows that this happens in the proxy:

ObjectDisposedException. Cannot access a disposed object. Object name: 'ServicedComponent'. at System.EnterpriseServices.ServicedComponentProxy.AssertValid()

The object itself is has not been disposed yet, I think it is the proxy that has been disposed and it doesn't allow any more method calls.

I would like to fix this by registering a reference to the object itself rather than to the proxy. I don't want to go through the proxy at all for my UpdateDisplay call from the timer callback thread.

How do I get the real object without the proxy in the way? Or is there a better way to do this: save an internal reference to a COM+ object and call an internal method later?