CMainFrame* pFrame=(CMainFrame* )pFrameClass->CreateObject();
ASSERT(pFrame->IsKindOf(RUNTIME_CLASS(CMainFrame)));
m_pMainWnd=pFrame;  CCreateContext context;
context.m_pCurrentFrame = pFrame;
context.m_pCurrentDoc = NULL;
context.m_pNewViewClass = RUNTIME_CLASS(CCdmaMapTestView);
context.m_pNewDocTemplate = NULL; if (!pFrame->LoadFrame(IDR_MAINFRAME,
    WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,   
    NULL, &context))//此处抛异常 debug assertion failed
                             //file: afxwin2.inl 
                             //line:96

解决方案 »

  1.   

    context.m_pCurrentFrame = pFrame;
    pFrame都还没出现那..
      

  2.   

    楼上两位大哥 其实说的都是一个问题 pFrame的窗体是否存在
    pFrame->LoadFrame(IDR_MAINFRAME,
                      WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,   
                      NULL, &context))//这句就是产生窗体的啊 
                                      //在它之前窗体当然没有产生
                                      //即使把第四个参数换为NULL,同样抛异常
                                      //产生窗体这步就抛异常 这怎么解决啊
                                       
    CFrameWnd::LoadFrame ==> CFrameWnd::Create ==>CWnd::CreateEx ==>::CreateWindowEx ==>
    触发WM_CREATE  最后CMainFrame::OnCreate
      

  3.   

    问题很可能是(CMainFrame* )pFrameClass->CreateObject();造成的.你重点追踪下PFrameClass变量.
      

  4.   

    不是说是CreateObject()造成的,而是pFrameClass,是否为它分配空间等等.
      

  5.   

    另外,还有可能是m_pMainWnd=pFrame; 是它造成的.你的pFrame还没有LoadFrame,就把它赋值给m_pMainWnd=pFrame; 了.我查了我的MFC,
    //file: afxwin2.inl
    的96行是{ ASSERT(::IsWindow(m_hWnd)); ::GetWindowRect(m_hWnd, lpRect); }不知道你的是不是这样的信息?这样就更奇怪了.
    一般是if (!pFrame->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,
    NULL, &context))//此处抛异常 debug assertion failed
     return FALSE;
    然后再m_pMainWnd=pFrame;
    怎么会调用GetWindowRect?难道是你在创建子窗体?
    你给信息不够多,方便的话,给我的信箱里发一份:[email protected]