Exceptions problem

U

UmmagummA

Hi,
can anyone give me more informations on these exceptions:

1. "COM object that has been separated from its underlying RCW can not be
used."

2. "Unable to get the window handle for the 'some control' contol.
Windowless ActiveX controls are not supported"

Second exception is thrown on Dispose if the contol is created, but not
shown at all. When the control is shown then this exception is not thrown.
I don't know when the first exception shows up.

3. (Kinda related to 2.) How can i check is it some control disposed ?!
 
N

Nicholas Paldino [.NET/C# MVP]

UmmagummA,

For the first, it would mean that the wrapper has called Release on the
pointer to the interface that it is holding, decrementing its reference
count. Basically, if you pass a RCW to the static ReleaseComObject method
on the Marshal class, and then call a method on the wrapper, it will throw
this error.

For the second, some Active X controls don't create child windows in the
classic sense, rather, they handle the drawing of all the elements
themselves. In these cases, you will not be able to get window handles for
some of them. What are you trying to do here that you get that exception?
The controls in VBA in Microsoft Office (Microsoft Office Forms) are
windowless controls, for example.

There is really no way to tell if an object is disposed or not. If you
have to check this, it would indicate a flaw in your design, as you are
passing around objects which really should be just let go (after being
disposed).

Hope this helps.
 
A

Azhagan

As an addendum to what Nicholas mentioned, if you are to make sure your
COM objects are properly disposed off, try creating a new AppDomain and host
your COM objects there. When you are done using the COM object, delete the
AppDomain which will effectively delete all the resources used by it.

HTH,
-Azhagan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top