简体   繁体   中英

Out-of-process COM server

I have a 64-bit process and I have a 32-bit DLL. I hosted the DLL in an out-of-process COM Server; the COM server is an executable application (ie a surrogate process). The problem is that whenever my 64-bit process exits abruptly, the server cannot determine that there are no more references to the object and exit?

Any help!

Have your 64-bit process create a named mutex . Have your 32-bit COM server watch that mutex, and when invalidated/closed (ie-due to crash), just shutdown/stop/terminate.

If you need a solution that supports several different processes, then require each process to call some type of initialize function (to your COM server) that passes in some shared handle (a mutex or otherwise) and your COM server can add it to a list. When all handles are invalid or closed, shutdown.

You could also use a file -- 64-bit process locks a byte in a file using LockFile (or exclusive open file/etc), COM server tries to lock the file every few seconds, if it can, shutdown.

The point being, use any handle or method that will close/invalidate when a process crashes, that way the other process can detect it. If you don't want an extra handle around, just use a handle to the process itself. The named mutex is probably easiest to implement though, no extra functions or passing of handles required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM