程序结构:
 1. 基于MFC扩展Dll, 用它封装了CWinApp派生的一个类: CMSDApp,其内部仅有一个InitInstance() 无任何代码(仅一句 return true )
 2. TestFrame MFC对话框, CTestFrameApp由 CMSDApp派生。运行后出现: 
TestFrame.exe 中的 0x7c172faf (mfc71.dll) 处未处理的异常: 0xC0000005: 读取位置 0x00000000 时发生访问冲突 。  出错后定位在int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{
...
if (!pThread->InitInstance())   <---- 出错定位
...
}

解决方案 »

  1.   

    用 pThread 访问 InitInstance() 出错了. 可能 pThread 为 NULL
      

  2.   

    这个 ... 原因就多了, debug 检查哦.
      

  3.   

    以前都会出错现在我改了dll中的
    CMSDWndApp::CMSDWndApp()
    : CWinApp()   // 增加的 <--
    {
    }
    dll bebug -》exe bebug 运行就OK,其他的就还是不行。
      

  4.   

    建议吧错误代码到 msdn上边搜一下啊.
      

  5.   

    dll debug ==> exe debug 可以运行,也可调试
    dll release ==> exe release 可以运行,也可调试dll release ==> exe debug 就不行
    出错是因为读内存错,
    出错点:  
    if (!pThread->InitInstance())   <---- 出错定位  pThread == NULL