Article ID: 154744 - Last Review: November 21, 2006 - Revision: 4.1 You receive error messages in an MFC application when you upgrade from an earlier version of Visual C++ to Visual C++ 4.2 or a later versionThis article was previously published under Q154744 SYMPTOMS The error below may occur in an MFC application where one
of the following is assigned a value by the programmer: CWinApp::m_pszAppName CWinApp::m_pszRegistryKey CWinApp::m_pszExeName CWinApp::m_pszHelpFilePath CWinApp::m_pszProfileName Debug Assertion failed Program: my.exe File: dbgheap.c Line: 1017 Expression:_BLOCK_TYPE_IS_VALID(pHead->nBlockUse) Debug Assertion failed Program: my.exe File: dbgheap.c Line: 1011 Expression: _CrtIsValidHelpPointer(pUserData) CAUSE The CWinApp destructor in MFC included with Visual C++ 4.2
and later now frees the data assigned to the member variables shown above by
passing the pointer to the free() function. Doing this prevents memory leaks,
which would occur if an MFC regular DLL were dynamically loaded and unloaded.
STATUS This
behavior is by design. RESOLUTIONIf
you assign a value to m_pszAppName, m_pszRegistryKey, m_pszExeName,
m_pszHelpFilePath, or m_pszProfileName, the data must be dynamically allocated
on the heap. You may want to use the _tcsdup() run-time library function to do
this. Also, free the memory associated with the current pointer before assigning a new value. Here is an example: APPLIES TO
| Article Translations
|
Back to the top
