0
我有一個MFC應用程序,我從exe中調用mfc dll(vtkMFC.dll)。在那裏我得到了一個調試斷言,如下面的afxwin1.inl。assert afxcurrentinstancehandle null從exe中調用MFC dll
{ASSERT(afxCurrentInstanceHandle!= NULL);
我試圖用AfxSetResourceHandle(GetModuleHandle("vtkMFC.dll"))
,但仍然得到同樣的錯誤。 我正在使用"use MFC in a static library"
選項。 下面是我的代碼:
AFX_MANAGE_STATE(AfxGetStaticModuleState()) CWaitCursor WC; // sometimes takes a while to start CCCADApp *app = (CCCADApp *)AfxGetApp(); CFrameWnd *frame = app->pVtkTemplate->CreateNewFrame(this, NULL); // first init creates the view app->pVtkTemplate->InitialUpdateFrame(frame, this, FALSE); CvtkMDIView* view= dynamic_cast<CvtkMDIView*>(frame->GetActiveView()); // // automatic correction - try to load initial field if solution is not available if(run->GetStatus()==CDawesRun::NOTRUN) options=VTKInitialField|VTKGrid|(options & VTKView2D); if(view) view->setData(run,options,variable); // set data // show the view and frame app->pVtkTemplate->InitialUpdateFrame(frame, this, TRUE);
我的主要應用是建立與「多線程調試(/ MTD)」選項,該DLL是建立與多線程調試DLL(/ MDD )。 這是否與此有關? 請幫幫我。
謝謝。
非常感謝Ofek的回覆。我的主要項目是靜態鏈接的。所以我無法改變它。我的第三方lib和dll(vtk)文件是動態鏈接的。更改它們也沒有解決問題,因此我直接在主應用程序中使用了提供錯誤(vtkMFCWindow)的文件,並刪除了它的__declspec(dllexport)定義。現在它工作正常。再次感謝。 – gishara 2012-07-19 09:53:01