Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Problem with the module state Collapse All
Subject Author Date
Svetlozar Asenov Mar 21, 2006 - 10:22 AM

I recieve assertion failure in ASSERT_VALID below.

void CWnd::AssertValid() const
{
..............
        // should be a normal window
        ASSERT(::IsWindow(m_hWnd));

        // should also be in the permanent or temporary handle map
        CHandleMap* pMap = afxMapHWND();
        ASSERT(pMap != NULL);

        CObject* p=NULL;
        if(pMap)
        {
            ASSERT( (p = pMap->LookupPermanent(m_hWnd)) != NULL ||
HERE ---->     (p = pMap->LookupTemporary(m_hWnd)) != NULL);
        }
...........
}

I call a DLL function, which creates simple Dialog. CWnd::AssertValid() tries to find the m_hWnd handle in the thread handle map, but it cannot find it. It seems like problem with the module/thread state. My DLL is linked with ProfUIS 2.40 Unicode Debug RDE. In the InitInstance of the DLL, i’m calling CExt_ProfUIS_ModuleState::InitExtension(), as you suggest. Look at the stack dump:

    mfc80ud.dll!CWnd::AssertValid() Line 892 + 0x3f bytes    C++
    ProfUIS240ud.dll!CExtTabWnd::AssertValid() Line 812    C++
    ProfUIS240ud.dll!CExtTabMdiWhidbeyWnd::AssertValid() Line 6850    C++
    mfc80ud.dll!AfxAssertValidObject(const CObject * pOb=0x01f3c9c8, const char * lpszFileName=0x0108cc48, int nLine=1119) Line 107    C++
    ProfUIS240ud.dll!CExtTMWI<CExtTabWhidbeyWnd>::OnHookWndMsg(long & lResult=0, HWND__ * hWndHooked=0x00051554, unsigned int nMessage=553, unsigned int & wParam=0, long & lParam=1208068) Line 1120    C++
    ProfUIS240ud.dll!CExtHookSink::HookChains_t::HookChainsWindowProc(unsigned int nMessage=553, unsigned int & wParam=0, long & lParam=1208068) Line 164 + 0x26 bytes    C++
    ProfUIS240ud.dll!CExtHookSink::HookChains_t::g_HookWndProc(HWND__ * hWnd=0x00051554, unsigned int nMessage=553, unsigned int wParam=0, long lParam=1208068) Line 230 + 0x14 bytes    C++
    user32.dll!77d48734()     
..............
..............
    mfc80ud.dll!CWnd::SetFocus() Line 362 + 0xd bytes    C++
    ScriptEditor.dll!CScriptEditorWnd::OnInitDialog() Line 121    C++
    mfc80ud.dll!AfxDlgProc(HWND__ * hWnd=0x0003164a, unsigned int message=272, unsigned int __formal=136774, unsigned int __formal=136774) Line 28 + 0x10 bytes    C++


Thanks in advance for any help!

Technical Support Apr 22, 2009 - 9:02 AM

If the MFC state is managed correctly everywhere and if the correct RDE version of Prof-UIS is used and it’s also initialized correctly, then such assertions should not occur.

Please check everything described here first:

http://www.prof-uis.com/prof-uis/tech-support/faq/miscellaneous.aspx#how-to-use-prof-uis-in-my-dll-project

Then please check when exactly these assertions begin taking place.

In the best case, we would be happy to get a test project reproducing this assertion from you.

Technical Support Mar 21, 2006 - 12:10 PM

Please make sure that you used the AFX_MANAGE_STATE macro before creating the dialog:

AFX_MANAGE_STATE( AfxGetStaticModuleState() );



Svetlozar Asenov Mar 22, 2006 - 3:02 AM

Of course, i’m using it, but it still breaks down.

void CScripter::LaunchEditor()
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState( ));

    if (!m_bEngineCreated)
        return;

    CScriptEditorWnd scriptEdit;
    scriptEdit.pScripter = this;
    scriptEdit.SetScriptText(scriptText);
    scriptEdit.DoModal();
    scriptText = scriptEdit.GetScriptText();
}

Technical Support Mar 22, 2006 - 12:12 PM

We believe the error is hidden in some code snippet that we have not discussed yet. Would you send us your test project?

Svetlozar Asenov Mar 23, 2006 - 7:39 AM

I just sent you a testing project.

Robert Webb Apr 21, 2009 - 12:51 AM

Sorry to bump a very old thread, but I am now getting an assertion failure in exactly the same place in CWnd::AssertValid().


Was a solution ever found?  If so what was it?  For me it is happening when I open one of my dialogs, then close it again, or drop down a combo box within it, etc.


Thanks,


Rob.