Stuart Redmann
2010-04-14 14:03:51 UTC
Hello newsgroup,
I have the following problem with COM: I have a component inside an
OutProc server that is used by my application. This OutProc component
creates some InProc components that are used by application. Atfer
that, this OutProc component is not used any longer by the
application, so it is Release'd. Unfortunately, the OutProc server
will shut down because the ATL module management code thinks that all
components have been released. Upon shutdown the OutProc server will
destroy all those Inproc components that are still referenced by the
application!
I can think of two solutions to this problem:
(A) the COM standard says somewhere that you must not create InProc
components inside OutProc servers (unless you know that the life-time
of the OutProc components will extend the lifetime of the InProc
components). I could not find anything about this in my copy of Don
Box but that doesn't mean that such a restriction could not be out
there somewhere (I more or less accidentally found that one must not
make inter-apartment calls inside WM_PAINT handling routines on MSDN).
(B) The ATL implementation of InProc module life-time management is
faulty. I think that an easy way to avoid the problem would be to
launch some dummy thread during DllMain of InProc servers, thus
ensuring that the process of the OutProc server will only terminate
when all InProc servers can be unloaded safely.
Thanks in advance,
Stuart
I have the following problem with COM: I have a component inside an
OutProc server that is used by my application. This OutProc component
creates some InProc components that are used by application. Atfer
that, this OutProc component is not used any longer by the
application, so it is Release'd. Unfortunately, the OutProc server
will shut down because the ATL module management code thinks that all
components have been released. Upon shutdown the OutProc server will
destroy all those Inproc components that are still referenced by the
application!
I can think of two solutions to this problem:
(A) the COM standard says somewhere that you must not create InProc
components inside OutProc servers (unless you know that the life-time
of the OutProc components will extend the lifetime of the InProc
components). I could not find anything about this in my copy of Don
Box but that doesn't mean that such a restriction could not be out
there somewhere (I more or less accidentally found that one must not
make inter-apartment calls inside WM_PAINT handling routines on MSDN).
(B) The ATL implementation of InProc module life-time management is
faulty. I think that an easy way to avoid the problem would be to
launch some dummy thread during DllMain of InProc servers, thus
ensuring that the process of the OutProc server will only terminate
when all InProc servers can be unloaded safely.
Thanks in advance,
Stuart