我建了一个基于对话框的工程,在主对话框类里加入一个CPropertySheet类的一个成员变量(m_sheet)代表整个属性页。再加入一些各子对话框类的实例作为成员变量(m_page1、m_page2……),在主对话框类的OnInitDialog()函数中加入:
m_sheet.AddPage(&m_page1);
m_sheet.AddPage(&m_page2);
//用Create来创建一个属性页
m_sheet.Create(this, WS_CHILD | WS_VISIBLE, WS_EX_CONTROLPARENT);
这样在对话框中显示了属性页,我在第一个属性页中添加了一个Edit box控件用它来显示文件的路径,为此我用classwizad为它增加了一个控件变量
CString m_strFilePath;编译都没有问题,可是在运行的时候发生致命错误,报错显示为:
Debug Assertion Failed!
Program:F:\.........
File:afx.inl
Line:122
我把程序改为Realse下运行时,一切正常,不知道这是为什么?请问应该怎么解决?(使之在Debug下能够正常运行程序)

解决方案 »

  1.   

    我在成员变量的定义处设置了断点,单步执行后程序崩溃,报错如下:
    Unhandled exception in ***.exe:0xc0000005: Access Violation
    程序定位在对话框类的.cpp文件中的某一行:
    BOOL CFileBindApp::InitInstance()
    {
    AfxEnableControlContainer(); // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need.#ifdef _AFXDLL
    Enable3dControls(); // Call this when using MFC in a shared DLL
    #else
    Enable3dControlsStatic(); // Call this when linking to MFC statically
    #endif CFileBindDlg dlg;
    m_pMainWnd = &dlg;        *断点指示在这一行*
    int nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
    // TODO: Place code here to handle when the dialog is
    //  dismissed with OK
    }
    else if (nResponse == IDCANCEL)
    {
    // TODO: Place code here to handle when the dialog is
    //  dismissed with Cancel
    } // Since the dialog has been closed, return FALSE so that we exit the
    //  application, rather than start the application's message pump.
    return FALSE;
    }
      

  2.   

    哪位热心人帮忙解答一下啊,我现在不用classwizard添加控件变量,直接在第一个属性页类中点击右键添加成员变量,程序还是出现描述的错误!!!