assert afxcurrentinstancehandle null calling MFC dll from exe

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.

Answers


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?


Need Your Help

Animation jerks in android device in titanium

android animation titanium titanium-mobile

I have explore almost anything but couldn't find anything convincing which can verify that why animation jerks if try to animate any window through its animate property.

How do I trigger Ratchet's push manually?

javascript html5 mobile ratchet-2

I have a link which makes a search. So far, it's working. The issue is when I want the search to be done through hiting the 'enter' button. So: