0
votes

I have a MFC app where I am calling a mfc dll (vtkMFC.dll) from the exe. There I am getting a debug assertion as below in afxwin1.inl.

{ ASSERT(afxCurrentInstanceHandle != NULL);

I tried to use AfxSetResourceHandle(GetModuleHandle("vtkMFC.dll")) but still getting the same error. I am using "use MFC in a static library" option. Below is my code:

    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);

My main app is built with, "Multi-threaded Debug (/MTd)" option where the dll is built with, Multi-threaded Debug DLL (/MDd). Does it have something to do with this? Please help me.

Thanks.

1

1 Answers

0
votes

Why do you link statically against MFC/CRT? I'm not sure about MFC, but I believe linking against the CRT statically/dynamically in different modules of the application is not supported.

Can you try and build with /MDd, and link dynamically to MFC, and say if it helps?