Out-of-proc COM server stuck Out-of-proc COM server stuck windows windows

Out-of-proc COM server stuck


Your BHO (Browser Helper Object) is in a single thread appartment. Every COM call in a STA that is made to an object on another STA (different thread) is ordered by a message in a message queue before it is "transformed" in a method call.

This is usually not a problem, because most of the time calls are triggered by the GUI who is single threaded. COM calls wait their turn along with WM_LBUTTONUP messages and such.

What happens in your case is that while servicing onEvent, you send your BHO object to another thread, in another process, your out-of-process COM object. When you try to call back to the original object from your MTA appartment, a Windows message is posted to your BHO STA thread in the Internet Explorer process that hosts it. But the message queue is still busy servicing the original request.

That explains your deadlock, and why passing a string works.