各位大虾哥看看??
Debug Assertion Failed :
program:C:\...........\***.exe
File:dbgheap.c
line:1011Expression:_CrtIsValidHeapPointer(pUserData)我的生成对话框语句如下,是在一个Thread里生成的。
         Conv = new CConversation(NULL, pWith, pszDefaultMsg);
m_pMainWnd = Conv;
Conv->DoModal();
delete Conv;
其中对话框CConversation的构造函数如下(OnInitDialog())太长了,不列了, 

CConversation::CConversation(CWnd* pParent, CContact *With, char *DefaultMsg)
: CDialog(CConversation::IDD, pParent)
{
pszDefaultMessage = DefaultMsg;
Contact = With; BrushWhite.CreateSolidBrush(RGB(255, 255, 255)); 
BrushNormal.CreateSolidBrush(GetColor(COL_LINEFRAMES));
BrushLight.CreateSolidBrush(GetColor(COL_LIGHTITEMS));
BrushDisabled.CreateSolidBrush(GetColor(COL_DISABLED)); FontBold.CreateFont(13, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, 0, 0, "Tahoma");
FontNormal.CreateFont(13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Tahoma"); m_iSendFile = AfxGetApp()->LoadIcon(IDI_SENDFILE);
m_iSendFileD = AfxGetApp()->LoadIcon(IDI_SENDFILED);
m_iBlock = AfxGetApp()->LoadIcon(IDI_BLOCK);
m_iUnblock = AfxGetApp()->LoadIcon(IDI_UNBLOCK); HasMessage = false;
Enabled = true;
IsTransfering = false; //{{AFX_DATA_INIT(CConversation)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT memset(&ufFontNormal, 0, sizeof(USERFONT));
ufFontNormal.lfFont.lfHeight = 16;
ufFontNormal.lfFont.lfWeight = FW_NORMAL;
ufFontNormal.lfFont.lfQuality = 1;
strcpy(ufFontNormal.lfFont.lfFaceName, "MS Sans Serif");
ufFontNormal.nPointSize = 100;
ufFontNormal.crColor = RGB(0, 0, 0); m_SplitterPos = 0;
m_hIcon = AfxGetApp()->LoadIcon(IDR_CONVERSATION);
}

解决方案 »

  1.   

    不知道你的英语是否过了4级
    Error messages referencing dbgheap.c
    Occasionally a user will report that an app linked with the runtime SmartHeap lib (shdw32m(t).lib or shlw32m(t).lib) crashed with the error message 
    Debug Assertion Failed!
    program xxxx.exe
    File: dbgheap.c
    Line: 1011
    Expression: _CrtlsValidHeapPointer(pUserData) This error can only occur if Debug C runtime library or Debug MFC is used -- the file dbgheap.c is part of the debug VC CRT, as is the API CrtIsValidHeapPointer. So the invocation of this error in association with the Runtime SmartHeap libraries indicates a runtime/debug mismatch. Runtime SmartHeap does not support debug versions of the C runtime libraries. If your application links with the Debug C runtime library it must also link with the Debug SmartHeap library. 
      

  2.   

    好像没有,我在release版的时候Dialog可以显示,但关闭时会有错误,不知道咋回事
      

  3.   

    : sjsj(悠行者): 什么意思?
      

  4.   

    sjsj(悠行者)的 意思是说你的程序是调试版本的话要用调试版本的c的运行时库或者MFC的调试版本,如果是发行版本则要用发行版本的c运行时库或者MFC库来联接(link);所以建议你看看是否联接美设置,就在工程菜单下的自定义或选项子菜单sjsj(悠行者)的话可能是来源于MSDN或者是英文版的《win32程序调试》具有一定的可信度,建议试试;
      

  5.   

    If your application links with the Debug C runtime library it must also link with the Debug SmartHeap library. ?该怎么设置阿?
    我link了这些:
    ws2_32.lib mpr.lib winmm.liblink->project options:
    ws2_32.lib mpr.lib winmm.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/Netmsg.pdb" /debug /machine:I386 /def:".\Netmsg.def" /out:"Debug/Netmsg.exe" /pdbtype:sept c++->project options:
    /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_AFXDLL" /FR"Debug/" /Fp"Debug/Netmsg.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c 上面咋回事,是上面的问题吗?
    惭愧
      

  6.   

    CWnd在那里生成,
    如果跨线程操作MFC类实例,好像在操作之间要添加一个操作,你找一下MSDN,
    该函数以AfxGet开头的。