We help IT Professionals succeed at work.

Microsoft Management Console Snap-In crashes at exit...

baigmz
baigmz asked
on
Hi,

I have a Microsoft Management Console snap-in for Windows NT4.0. This snap-in provides functionality through a COM object. When the MMC is launched and the snap-in is added to it, the user can right click on a tree view node of the snap-in and launch a property sheet to modify attributes for the snap-in. When the sheet is OK'd or Cancel'd without modifying anything, it used to work fine on Windows NT4.0, IIS4.0 and bring back focus to MMC. I am now starting the effort to port this snap-in onto Windows 2000 (Server). I haven't changed any code at all but when I do a OK or cancel, the snap-in crashes.

The unhandled exception drills down to this point of C library code (below). [see the commented line] How's the tooltip fall in the picture??

_AFX_THREAD_STATE::~_AFX_THREAD_STATE()
{
     // cleanup thread local tooltip window
     if (m_pToolTip != NULL)
     {
/**CRASHES HERE---->*/ m_pToolTip->DestroyWindow();
                       delete m_pToolTip;
     }

     // unhook windows hooks
     if (m_hHookOldMsgFilter != NULL)
          ::UnhookWindowsHookEx(m_hHookOldMsgFilter);
     if (m_hHookOldCbtFilter != NULL)
          ::UnhookWindowsHookEx(m_hHookOldCbtFilter);

     // free safety pool buffer
     if (m_pSafetyPoolBuffer != NULL)
          free(m_pSafetyPoolBuffer);

     // parking window must have already been cleaned up by now!
     ASSERT(m_pWndPark == NULL);
}


When the property sheet is destroyed, it calls the MMCFreeNotifyHandle function in the destructor and then delete's it's own object as well.

Any idea why this may be crashing now? It's the exact same code on NT4.0, IIS4.0. It now crashes on Win2k, IIS5.0. The one thing different between the two MMC consoles is that the left side treeview in MMC on Win2k is placed on a property sheet itself whereas the IIS4.0 implementation just contains the tree without any other pages. How does the "m_pToolTip->DestroyWindow()" result to a crash when this wasn't the problem in IIS4.0 on NT4?
The address of m_pToolTip is 0xdddddddd, which is strange.

Thanks in advance for valuable inputs.
Comment
Watch Question

By the time the destructor is called, the tooltip window handle has already been destroyed.  Although the m_pToolTip variable is still valid, the tooltip window itself was probably destroyed during the OnClose event.  

Check the window handle itself by calling:
m_pToolTip->GetSafeHwnd()  // this assumes you're using MFC, which it looks like from your question.

to see if it's a valid handle or NULL.

Child windows automatically get destroyed when their parent window is destroyed.  And, that's what looks like is happening here.

Author

Commented:
Thanks. How's the relationship between the parent and child windows differ from what was previously governed by the MMC console in IIS4.0 running on NT4.0? It seemed to be fine there. It's only crashing in IIS5.0 on Win2k.

Commented:
Hi,

I had a similar behaviour.

I was calling CoUnitialize() too early. Ia ma not sure when and if at all to call it correctly but since I do not call it any longer, my snapin works.

Commented:
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "DarthPedro" comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: http://www.experts-exchange.com/commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner

Commented:
baigmz

You have 11 open questions out of 89 that need your attention. Please accept an answer if you received help or provide feedback to the experts when needed.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Per recommendation, force-accepted by
Netminder
CS Moderator

Explore More ContentExplore courses, solutions, and other research materials related to this topic.