From: KellyLynch on
Language: Visual C++ 6.0; MFC app with CWinApp-based class
OS: WinXP


I use a COM component (http://www.emailarchitect.net/webapp/popcom/)
in MFC app. I release it BEFORE call of ExitInstance; in ExitInstance
I call CoUninitialize. This CoUninitialize hangs. If I call
CoUninitialize not from ExitInstance but right after the COM object is
released - no hangs.

All I know about this COM component is it uses asyncronous mode amd
uses sink interfaces for client notification. Partially it uses ATL's
method DispEventAdvise. My application has not its own cycles of
message processing - only standard MFC cycle in CWinApp.

The hang does not depend on what was used to initialize COM:
CoInitialize( NULL ) or CoInitializeEx(NULL, COINIT_APARTMENTTHREADED).
From: Alf P. Steinbach on
* KellyLynch:
> Language: Visual C++ 6.0; MFC app with CWinApp-based class
> OS: WinXP
>
>
> I use a COM component (http://www.emailarchitect.net/webapp/popcom/)
> in MFC app. I release it BEFORE call of ExitInstance; in ExitInstance
> I call CoUninitialize. This CoUninitialize hangs. If I call
> CoUninitialize not from ExitInstance but right after the COM object is
> released - no hangs.
>
> All I know about this COM component is it uses asyncronous mode amd
> uses sink interfaces for client notification. Partially it uses ATL's
> method DispEventAdvise. My application has not its own cycles of
> message processing - only standard MFC cycle in CWinApp.
>
> The hang does not depend on what was used to initialize COM:
> CoInitialize( NULL ) or CoInitializeEx(NULL, COINIT_APARTMENTTHREADED).

I've had this problem long ago, and it turned out (but I never fixed the app
properly, using instead some other work-around) that initalizing COM "late",
relying on the fact that you can have nested init/uninit calls, was to blame.

Since you're using MFC that's perhaps unlikely, but anyway, try to put COM/OLE
initialization as about the first that ever happens in the app.



Cheers & hth (even though unlikely with MFC),

- Alf


PS: Try upgrading your compiler. Yes, 6.0 had the bestest IDE, DevStudio, but
that was long ago. You can download Visual Studio Express for free from MS.
From: KellyLynch on
On 15 фев, 11:40, "Alf P. Steinbach" <al...(a)start.no> wrote:
> * KellyLynch:
>
>
>
> > Language: Visual C++ 6.0; MFC app with CWinApp-based class
> > OS: WinXP
>
> > I use a COM component (http://www.emailarchitect.net/webapp/popcom/)
> > in MFC app. I release it BEFORE call of  ExitInstance; in ExitInstance
> > I call CoUninitialize. This CoUninitialize hangs. If I call
> > CoUninitialize not from ExitInstance but right after the COM object is
> > released - no hangs.
>
> > All I know about this COM component is it uses asyncronous mode amd
> > uses sink interfaces for client notification. Partially it uses ATL's
> > method DispEventAdvise. My application has not its own cycles of
> > message processing - only standard MFC cycle in CWinApp.
>
> > The hang does not depend on what was used to initialize COM:
> > CoInitialize( NULL ) or CoInitializeEx(NULL, COINIT_APARTMENTTHREADED).
>
> I've had this problem long ago, and it turned out (but I never fixed the app
> properly, using instead some other work-around) that initalizing COM "late",
> relying on the fact that you can have nested init/uninit calls, was to blame.
>
> Since you're using MFC that's perhaps unlikely, but anyway, try to put COM/OLE
> initialization as about the first that ever happens in the app.
>
> Cheers & hth (even though unlikely with MFC),
>
> - Alf
>
> PS: Try upgrading your compiler. Yes, 6.0 had the bestest IDE, DevStudio, but
> that was long ago. You can download Visual Studio Express for free from MS.

The same problem was on Visual C++ 2005