none
Outlook addin "debug assertion failed" when running a debug build from VS2010 RRS feed

  • Question

  • I have an Outlook 2007 COM addin (native C++ with ATL) that adds a propertysheet to the Outlook Tools/Options area using the Application Event OptionsPagesAdd.  It has only one button control on the displayed page.  I was previously building the addin with Visual Studio 2008 and had no issues with either a release or debug build.  I've switched to Visual Studio 2010 and the release build has no errors but the debug build generates a run-time error.

    If, in Outlook 2007, I select Tools/Options/MyPropertyPage and click on my test button, the button functions as designed.  However, when I click OK to dismiss the Tools/Options page, I get the following error:

    Microsoft Visual C++ Debug Library

    Debug Assertion Failed!

    Program: C:\Program Files (x86)\Microsoft Office\Office12\OUTLOOK.EXE
    File: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlctl.h
    Line: 1897

    Expression: hWnd!=0

    The button code is as follows.

    LRESULT CPropPage::OnBnClickedButton1(WORD , WORD, HWND, BOOL& )
      {
      Beep(1000,100);
      return 0;
      }
    
    

    If the page is displayed and the button is not clicked, there is no error.  How can I prevent this error from happening, or can it be trapped so that it doesn't diaplay?

     


    Mark Wilson
    Sunday, February 5, 2012 8:08 PM

All replies

  • Hi Mark,

    Let me see if I can reproduce this locally.

    Dave

    Monday, February 6, 2012 9:13 PM
  • Hi Mark,

    I can now reproduce this locally.  However, I am not sure at this moment why this is occurring. I will keep looking at it and let you know.

    Dave

    Monday, February 13, 2012 3:28 PM
  • Hi Dave, 

    I am facing the same problem even after replacing  "#include <atlctl.h>" with below code

    #pragma push_macro("ATLASSUME")
    #undef ATLASSUME
    #define ATLASSUME(x)
    #include <atlctl.h>
    #pragma pop_macro("ATLASSUME")

    Can you suggest any better solution? I am using Visual Studio 2010.

    Thursday, November 6, 2014 9:22 AM
  • Hello Rinkesh.

    My issue wasn't solved in this forum.  I opened a support case for it (REF: 112041643927630).  Microsoft said that this was a bug in Visual Studio 2010 (SP1).  This was a problem with the Microsoft code.  Their support person said "The ASSERT is wrongly placed. The fix suggested is to comment out the ASSERT and rebuild your code." 

    I edited the Microsoft ATLCTL.H file as follows and recompiled.

    HRESULT IOleInPlaceObject_UIDeactivate(void)
    {
    if (m_hWndFocus != NULL)
      {
      HWND hWnd = m_hWndFocus;
      do
        {
        hWnd = ::GetParent(hWnd);
        }
        while (hWnd != NULL && ::GetParent(hWnd) != m_hWnd);
        if (hWnd != m_hWndFocus)
          {
          //ATLASSUME(hWnd != NULL);
          CComPtr<IUnknown> spUnknown;
          HRESULT hr = AtlAxGetControl(hWnd, &spUnknown);
          if (SUCCEEDED(hr))
            {
            CComPtr<IOleInPlaceObject> spIOleInPlaceObject;
            hr = spUnknown->QueryInterface(&spIOleInPlaceObject);
            if (SUCCEEDED(hr))
              spIOleInPlaceObject->UIDeactivate();
            }
          }
      }
    m_hWndFocus = NULL;
    return CComControl<T, CAxDialogImpl<T> >::IOleInPlaceObject_UIDeactivate();
    return S_OK;
    }

    That stopped "debug assertion failed" issue for me.


    Mark Wilson


    • Edited by Mark_Wilson Thursday, November 6, 2014 1:02 PM
    Thursday, November 6, 2014 1:02 PM