MFC has issues with multiple threads and possibly also with dlls. In this case GetParentFrame() is the culprit as it makes an internal call to CWnd::FromHandle which looks like this:
CWnd* PASCAL CWnd::FromHandle(HWND hWnd)<br />{<br /> CHandleMap* pMap = afxMapHWND(TRUE);
The afxMapHWND func is probably trying to use global structures that aren't visible from the dll.