dll problem
-
Hello, I have an application which works fine . I have now made DLL of the classes which I use.In one of the classes it has a statement which calls the ParentFrame and sets the menu. GetParentFrame()->SetMenu(&FrameMenu); But when I use DLL in my application I get an unhandled error where it seems that the Parent Frame is not found What must be the problem? When I debug he application with DLL the debug cursor does not enter inside the DLL's .cpp file .I want to enter the DLL code .What should be done for that? Pritha
-
Hello, I have an application which works fine . I have now made DLL of the classes which I use.In one of the classes it has a statement which calls the ParentFrame and sets the menu. GetParentFrame()->SetMenu(&FrameMenu); But when I use DLL in my application I get an unhandled error where it seems that the Parent Frame is not found What must be the problem? When I debug he application with DLL the debug cursor does not enter inside the DLL's .cpp file .I want to enter the DLL code .What should be done for that? Pritha
-
To debug your DLL, Set DLL project as active and under Project->Settings->Executable for Debug session browse the exe which is using your DLL.
-
Hello, I have an application which works fine . I have now made DLL of the classes which I use.In one of the classes it has a statement which calls the ParentFrame and sets the menu. GetParentFrame()->SetMenu(&FrameMenu); But when I use DLL in my application I get an unhandled error where it seems that the Parent Frame is not found What must be the problem? When I debug he application with DLL the debug cursor does not enter inside the DLL's .cpp file .I want to enter the DLL code .What should be done for that? Pritha
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)
{
CHandleMap* pMap = afxMapHWND(TRUE); //create map if not exist
ASSERT(pMap != NULL);
CWnd* pWnd = (CWnd*)pMap->FromHandle(hWnd);#ifndef _AFX_NO_OCC_SUPPORT
pWnd->AttachControlSite(pMap);
#endifASSERT(pWnd == NULL || pWnd->m\_hWnd == hWnd); return pWnd;
}
The afxMapHWND func is probably trying to use global structures that aren't visible from the dll.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
-
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)
{
CHandleMap* pMap = afxMapHWND(TRUE); //create map if not exist
ASSERT(pMap != NULL);
CWnd* pWnd = (CWnd*)pMap->FromHandle(hWnd);#ifndef _AFX_NO_OCC_SUPPORT
pWnd->AttachControlSite(pMap);
#endifASSERT(pWnd == NULL || pWnd->m\_hWnd == hWnd); return pWnd;
}
The afxMapHWND func is probably trying to use global structures that aren't visible from the dll.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
-
Hello, Thanks But I aam using 2 DLLs and How should I debug starting from my client project? Pritha
prithaa wrote:
But I aam using 2 DLLs and How should I debug starting from my client project?
Set your dll project as the startup/active project. So when you press F5 you get a dialog prompting you to enter an exe name which will be hosting or using this dll, here browse and select the main exe which runs using this dll.
Nibu babu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com
-
hello, thanks for the reply. So I should not use the GetParentFrame() function.And what care should be taken regarding functions that go into the DLLs Pritha
Can you avoid using MFC functions from the dll? Here you could use ::GetParent(m_hWnd) instead of GetParentFrame(), but it would give you a HWND, not CFrameWnd. If you can use only raw winapi calls it should be OK.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
-
Hello, I have an application which works fine . I have now made DLL of the classes which I use.In one of the classes it has a statement which calls the ParentFrame and sets the menu. GetParentFrame()->SetMenu(&FrameMenu); But when I use DLL in my application I get an unhandled error where it seems that the Parent Frame is not found What must be the problem? When I debug he application with DLL the debug cursor does not enter inside the DLL's .cpp file .I want to enter the DLL code .What should be done for that? Pritha
If you use MFC with DLLs properly, you won't have a problem. Everything you need to know can be found here: Kinds of DLLs[^] Read carefully :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: