以前写过几个只导出函数的DLL,现在需要导出MFC继承类(具体的说是CView的继承类,用的是AFX_EXT_CLASS宏定义)
试过以后发现用debug版本编出的dll放在主程序中运行时会出问题,但用release版本的dll运行就不会有问题,不知,在CMyView中仅仅实现了一个对鼠标的左键点击的消息处理函数,且这个消息处理函数就是弹出一个MessageBox,各位分析一下是什么原因?

解决方案 »

  1.   

    代码不是偶写的,在MDI程序中重载CChildFrame::OnCreateClient()函数
    在CChildFrame定义:
    CSplitterWnd m_SplitWnd;BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if (!m_SplitWnd.CreateStatic(this,1,2)) 
    {
    TRACE0("Failed to CreateStaticSplitter\n");
    return FALSE;
    }
    if (!m_SplitWnd.CreateView(0,0,
    pContext->m_pNewViewClass,CSize(100,100),pContext)) 
    {
    TRACE0("Failed to CreateStaticSplitter\n");
    return FALSE;
    }
    // add the second splitter pane - an input view in column 1
            //这句出的问题!!
    if (!m_SplitWnd.CreateView(0, 1,
    RUNTIME_CLASS(CMyView1), CSize(100, 100), pContext))
    {
    TRACE0("Failed to create second pane\n");
    return FALSE;
    }
    AfxMessageBox(TEXT("444")); // activate the input view
    SetActiveView((CView*)m_SplitWnd.GetPane(0,1));
    AfxMessageBox(TEXT("777"));
    return TRUE;
    //return CMDIChildWnd::OnCreateClient(lpcs, pContext);
    }貌似是这个m_SplitWnd使用的问题,各位看看?
    跟踪了一下,到了CSplitterWnd::CreateView()中的这句话:
    ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd)));
    出先错误,难道我的CMyView1不是CWnd的继承类么?ps:我的CMyView定义:
    class AFX_EXT_CLASS CMyView1 : public CView
    {
    ...
    }
    各位看看?
      

  2.   

    好像找到原因了,貌似Dll是Release版本的,但主程序是debug版本就会出现这个问题,如果两个都是debug版本的,就没有问题了,奇怪的是,为甚会在ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd)))这个地方提示错误,奇怪也哉
      

  3.   

    no, using multiple versions of MFC (yes, this includes the debug and release version of MFC with the same version number) in different DLL's and passing MFC data between them is not supported.  int's, handles, and other non-MFC stuff should work.
      

  4.   

    懂了,十分感谢jiangsheng(蒋晟.Net[MVP]),结帖