From: sb on
I figured out that the root of my problem was an imbalance of
CoInitialize and CoUnitialize calls.

Thanks for the help.

sb wrote:
> I'm using the Create method. The core problem is that someone is
> calling CoUninitialize on my main thread (the one that called
> AfxOleInit) many times usually it is balance with a call to
> CoInitialize. If I make sure and call CoIniatialize right before
> calling DoModal the problem goes away...but, I don't understand why I'm
> seeing in the debugger that ole32!CoUninitialize breakpoints are hit so
> many times. Here are some examples:
>
> 0012d678 7c9fe24f ole32!CoUninitialize
> 0012d8a4 7c9f1b7e SHELL32!_CreateFolderIDList+0x155
> 0012d8cc 7c9ef455 SHELL32!_GetFolderIDListCached+0x84
> 0012d8f0 7ca26638 SHELL32!SHGetFolderLocation+0x9e
> 0012d924 7ca2668c SHELL32!_ReparentAliases+0x49
> 0012d940 7ca266d7 SHELL32!SHILAliasTranslate+0x17
> 0012d97c 7c9ede50 SHELL32!CDesktopFolder::ParseDisplayName+0xbe
> 0012d9e4 7c9edd9d SHELL32!CRegFolder::ParseDisplayName+0x93
> 0012da1c 7ca01aab SHELL32!SHParseDisplayName+0xa3
> 0012da4c 7ca018ff SHELL32!CShellExecute::_PerfPidl+0x4e
> 0012da60 7ca01896 SHELL32!CShellExecute::ExecuteNormal+0x46
> 0012da74 7ca01832 SHELL32!ShellExecuteNormal+0x30
> 0012da90 7ca40c92 SHELL32!ShellExecuteExW+0x8d
> 0012eb3c 7ca40f19 SHELL32!ShellExecuteExA+0x203
> 0012eb8c 025f5ddf SHELL32!ShellExecuteA+0x69
>
>
> 0012b328 7e27e725 ole32!CoUninitialize
> 0012b330 7e27eb20 ieframe!SHCoUninitialize+0x10
> 0012b34c 7e27e99e ieframe!SHGetNameAndFlagsW+0x78
> 0012c3cc 7e27eb4a ieframe!IEGetNameAndFlagsEx+0xf2
> 0012c3ec 7e277ea7 ieframe!IEGetDisplayName+0x1c
> 0012c400 7e215aa0 ieframe!CBaseBrowser2::IEGetDisplayName+0x13
> 0012e544 7e21591b ieframe!CIEFrameAuto::_NavigateHelper+0x30d
> 0012e578 7e2155e3 ieframe!CIEFrameAuto::Navigate+0xd4
> 0012e59c 7829d201 ieframe!CWebBrowserOC::Navigate+0x5e
>
>
> 0010b3b8 7e27e725 ole32!CoUninitialize
> 0010b3c0 7e27eb20 ieframe!SHCoUninitialize+0x10
> 0010b3dc 7e27e99e ieframe!SHGetNameAndFlagsW+0x78
> 0010c45c 7e27eb4a ieframe!IEGetNameAndFlagsEx+0xf2
> 0010c47c 7e264d02 ieframe!IEGetDisplayName+0x1c
> 0010c498 7e232a47
> ieframe!CDocObjectHost::CDOHBindStatusCallback::_GetUrl+0x4d
> 0010d51c 61423bc5
> ieframe!CDocObjectHost::CDOHBindStatusCallback::GetBindInfo+0x177
> 0010d530 6142413b urlmon!CBSCHolder::GetBindInfo+0x28
> 0010d548 61423ddd urlmon!CBinding::CallGetBindInfo+0x23
> 0010d5c0 61423cb7 urlmon!CBinding::StartBinding+0xea
> 0010d604 61441390 urlmon!CUrlMon::StartBinding+0x169
> 0010d640 7e23379a urlmon!CUrlMon::BindToObject+0xd5
> 0010d678 7e22a8c6 ieframe!CDocObjectHost::_StartAsyncBinding+0x19e
> 0010e720 7e2296c0 ieframe!CDocObjectHost::SetTarget+0x610
> 0010e758 7e22957d ieframe!CDocObjectView::CreateViewWindow2+0xf4
> 0010e78c 7e229810 ieframe!CDocObjectView::CreateViewWindow+0x3a
> 0010e848 7e22972e ieframe!FileCabinet_CreateViewWindow2+0x29d
> 0010e870 7e229c6c ieframe!CBaseBrowser2::CreateViewWindow+0x4a
> 0010e8b8 7e229a82 ieframe!CBaseBrowser2::_CreateNewShellView+0x262
> 0010e8e8 7e2299b3 ieframe!CBaseBrowser2::_CreateNewShellViewPidl+0xe3
> 0010f96c 7e25fe44 ieframe!CBaseBrowser2::_NavigateToPidl+0x20a
> 0010fbc0 7e25ff76 ieframe!CBaseBrowser2::_OnGoto+0x31a
> 0010fbd4 7e21c312 ieframe!CBaseBrowser2::WndProcBS+0x430
> 0010fbf4 7e21c394 ieframe!CWebBrowserSB::WndProcBS+0x1b
> 0010fc20 7e286b54 ieframe!CWebBrowserOC::v_WndProc+0x75
> 0010fc44 77d48734 ieframe!CImpWndProc::s_WndProc+0x65
> 0010fc70 77d48816 USER32!InternalCallWinProc+0x28
> 0010fcd8 77d4b89b USER32!UserCallWinProcCheckWow+0x150
> 0010fd14 77d4b903 USER32!SendMessageWorker+0x4a5
> 0010fd34 7e260647 USER32!SendMessageW+0x7f
> 0010fd4c 7e260675 ieframe!CBaseBrowser2::_SendAsyncOperation+0x23
> 0010fd64 7e25fece ieframe!CBaseBrowser2::_NavigateToPidlAsync+0xa2
> 0010fd84 7e25ffb3 ieframe!CBaseBrowser2::BrowseObject+0x15c
> 0010fd98 7e213cc7 ieframe!CIEFrameAuto::_BrowseObject+0x25
> 00111ed4 7e21591b ieframe!CIEFrameAuto::_NavigateHelper+0x53b
> 00111f08 7e2155e3 ieframe!CIEFrameAuto::Navigate+0xd4
> 00111f2c 7829d201 ieframe!CWebBrowserOC::Navigate+0x5e

From: AliR (VC++ MVP) on
I am glad you got it fixed.

AliR.

"sb" <shawnberg(a)gmail.com> wrote in message
news:1165349042.932282.145020(a)l12g2000cwl.googlegroups.com...
> I figured out that the root of my problem was an imbalance of
> CoInitialize and CoUnitialize calls.
>
> Thanks for the help.
>
> sb wrote:
> > I'm using the Create method. The core problem is that someone is
> > calling CoUninitialize on my main thread (the one that called
> > AfxOleInit) many times usually it is balance with a call to
> > CoInitialize. If I make sure and call CoIniatialize right before
> > calling DoModal the problem goes away...but, I don't understand why I'm
> > seeing in the debugger that ole32!CoUninitialize breakpoints are hit so
> > many times. Here are some examples:
> >
> > 0012d678 7c9fe24f ole32!CoUninitialize
> > 0012d8a4 7c9f1b7e SHELL32!_CreateFolderIDList+0x155
> > 0012d8cc 7c9ef455 SHELL32!_GetFolderIDListCached+0x84
> > 0012d8f0 7ca26638 SHELL32!SHGetFolderLocation+0x9e
> > 0012d924 7ca2668c SHELL32!_ReparentAliases+0x49
> > 0012d940 7ca266d7 SHELL32!SHILAliasTranslate+0x17
> > 0012d97c 7c9ede50 SHELL32!CDesktopFolder::ParseDisplayName+0xbe
> > 0012d9e4 7c9edd9d SHELL32!CRegFolder::ParseDisplayName+0x93
> > 0012da1c 7ca01aab SHELL32!SHParseDisplayName+0xa3
> > 0012da4c 7ca018ff SHELL32!CShellExecute::_PerfPidl+0x4e
> > 0012da60 7ca01896 SHELL32!CShellExecute::ExecuteNormal+0x46
> > 0012da74 7ca01832 SHELL32!ShellExecuteNormal+0x30
> > 0012da90 7ca40c92 SHELL32!ShellExecuteExW+0x8d
> > 0012eb3c 7ca40f19 SHELL32!ShellExecuteExA+0x203
> > 0012eb8c 025f5ddf SHELL32!ShellExecuteA+0x69
> >
> >
> > 0012b328 7e27e725 ole32!CoUninitialize
> > 0012b330 7e27eb20 ieframe!SHCoUninitialize+0x10
> > 0012b34c 7e27e99e ieframe!SHGetNameAndFlagsW+0x78
> > 0012c3cc 7e27eb4a ieframe!IEGetNameAndFlagsEx+0xf2
> > 0012c3ec 7e277ea7 ieframe!IEGetDisplayName+0x1c
> > 0012c400 7e215aa0 ieframe!CBaseBrowser2::IEGetDisplayName+0x13
> > 0012e544 7e21591b ieframe!CIEFrameAuto::_NavigateHelper+0x30d
> > 0012e578 7e2155e3 ieframe!CIEFrameAuto::Navigate+0xd4
> > 0012e59c 7829d201 ieframe!CWebBrowserOC::Navigate+0x5e
> >
> >
> > 0010b3b8 7e27e725 ole32!CoUninitialize
> > 0010b3c0 7e27eb20 ieframe!SHCoUninitialize+0x10
> > 0010b3dc 7e27e99e ieframe!SHGetNameAndFlagsW+0x78
> > 0010c45c 7e27eb4a ieframe!IEGetNameAndFlagsEx+0xf2
> > 0010c47c 7e264d02 ieframe!IEGetDisplayName+0x1c
> > 0010c498 7e232a47
> > ieframe!CDocObjectHost::CDOHBindStatusCallback::_GetUrl+0x4d
> > 0010d51c 61423bc5
> > ieframe!CDocObjectHost::CDOHBindStatusCallback::GetBindInfo+0x177
> > 0010d530 6142413b urlmon!CBSCHolder::GetBindInfo+0x28
> > 0010d548 61423ddd urlmon!CBinding::CallGetBindInfo+0x23
> > 0010d5c0 61423cb7 urlmon!CBinding::StartBinding+0xea
> > 0010d604 61441390 urlmon!CUrlMon::StartBinding+0x169
> > 0010d640 7e23379a urlmon!CUrlMon::BindToObject+0xd5
> > 0010d678 7e22a8c6 ieframe!CDocObjectHost::_StartAsyncBinding+0x19e
> > 0010e720 7e2296c0 ieframe!CDocObjectHost::SetTarget+0x610
> > 0010e758 7e22957d ieframe!CDocObjectView::CreateViewWindow2+0xf4
> > 0010e78c 7e229810 ieframe!CDocObjectView::CreateViewWindow+0x3a
> > 0010e848 7e22972e ieframe!FileCabinet_CreateViewWindow2+0x29d
> > 0010e870 7e229c6c ieframe!CBaseBrowser2::CreateViewWindow+0x4a
> > 0010e8b8 7e229a82 ieframe!CBaseBrowser2::_CreateNewShellView+0x262
> > 0010e8e8 7e2299b3 ieframe!CBaseBrowser2::_CreateNewShellViewPidl+0xe3
> > 0010f96c 7e25fe44 ieframe!CBaseBrowser2::_NavigateToPidl+0x20a
> > 0010fbc0 7e25ff76 ieframe!CBaseBrowser2::_OnGoto+0x31a
> > 0010fbd4 7e21c312 ieframe!CBaseBrowser2::WndProcBS+0x430
> > 0010fbf4 7e21c394 ieframe!CWebBrowserSB::WndProcBS+0x1b
> > 0010fc20 7e286b54 ieframe!CWebBrowserOC::v_WndProc+0x75
> > 0010fc44 77d48734 ieframe!CImpWndProc::s_WndProc+0x65
> > 0010fc70 77d48816 USER32!InternalCallWinProc+0x28
> > 0010fcd8 77d4b89b USER32!UserCallWinProcCheckWow+0x150
> > 0010fd14 77d4b903 USER32!SendMessageWorker+0x4a5
> > 0010fd34 7e260647 USER32!SendMessageW+0x7f
> > 0010fd4c 7e260675 ieframe!CBaseBrowser2::_SendAsyncOperation+0x23
> > 0010fd64 7e25fece ieframe!CBaseBrowser2::_NavigateToPidlAsync+0xa2
> > 0010fd84 7e25ffb3 ieframe!CBaseBrowser2::BrowseObject+0x15c
> > 0010fd98 7e213cc7 ieframe!CIEFrameAuto::_BrowseObject+0x25
> > 00111ed4 7e21591b ieframe!CIEFrameAuto::_NavigateHelper+0x53b
> > 00111f08 7e2155e3 ieframe!CIEFrameAuto::Navigate+0xd4
> > 00111f2c 7829d201 ieframe!CWebBrowserOC::Navigate+0x5e
>