Click here to Skip to main content
16,016,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on migration of development environment of a scanner code from xp to win 7. For that I have upgraded the code in VS 2008, all the compilation errors are fixed. On release mode, the code is working fine. But upon installing the application in the device, it is crashing and closing abruptly on traversing back (using “Esc” button).

Upon checking the code in debug mode, it throws an error


C++
Debug assertion failed!
File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp


On trying to debug the error, it redirect me to the code segment mentioned below:

C++
BOOL CWnd::Attach(HWND hWndNew)
{
    ASSERT(m_hWnd == NULL);     // only attach once, detach on destroy
    ASSERT(FromHandlePermanent(hWndNew) == NULL);
        // must not already be in permanent map

    if (hWndNew == NULL)
        return FALSE;

    CHandleMap* pMap = afxMapHWND(TRUE); // create map if not exist
    ASSERT(pMap != NULL);

    pMap->SetPermanent(m_hWnd = hWndNew, this);


#ifndef _AFX_NO_OCC_SUPPORT
    AttachControlSite(pMap);
#endif

    return TRUE;
}


Please let me know how to solve the issue? Does any project settings need to be fixed? Any help is welcome.. Thanks

What I have tried:

I have tried to find the source of the error but no luck..
Posted
Updated 8-Feb-18 21:03pm

1 solution

You have to find the code that calls Attach(). The Wnd for which the function is called is already attached (m_hWnd not NULL) or the passed hWndNew is already in the permanent map.

The calling function might be also from the MFC library. If so, you have to find your code which finally calls a MFC function and check the state of the CWnd there.

To do this inspect the call stack when execution stops due to the assertion. If that does not include code from your sources, you have to use break points until you know your code portion that finally results in the assertion.

I'm not sure about the side effects here (in release build) but guess that it will result in memory leaks.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900