AfxGetResourceHandle gives debug assertion
We had an application which was built using VC6, and it loads a
dll(that uses MFC library) to create a splitter view. Previously this
dll was built using VC6. But now we have migrated the dll project to
VC8. And all the problems started coming after that.
This dll has some APIs which directly gets called from the exe. One of
them is for creating the view. We have swapped the resource handles
before making any MFC related calls(e.g., CSplitterWnd::CreateView())
in that API. Below is the call sequence for that:
if (hNew == NULL)
hNew = _ixia_GetInstanceHandle();
m_hOld = NULL;
if (hNew)
{
m_hOld = AfxGetResourceHandle();
AfxSetResourceHandle(hNew);
}
splitterWnd.CreateView(0,0,
RUNTIME_CLASS(CProtocolTreeCtrl), CSize(200, 200), NULL);
I was having no issue in VC6 with these calls. But in VC8
AfxGetResourceHandle() is giving an debug assertion, and returning
NULL. And after that CSplitterWnd::CreateView() fails to execute.
I have also checked that if I place the call AfxGetResourceHandle() in
InitInstance() method of the app class it does not give the assert.
Do you have any idea what's going wrong here.