I have a dialog-based app that causes assert whenever I try to do DoModal on any dialog. This happens in the release build only - debug works fine.
A bit of poking around pointed to the source of assert in AfxGetResourceHandle():
ASSERT(afxCurrentResourceHandle != NULL)
The confusing part is that I call AfxGetResourceHandle() just before doing dlg.DoModal() that is failing, and returned HINSTANCE is fine.
So, something changes from the start of CDialog::DoModal to the point where AfxGetResourceHandle() is called, that I just can't see:
// can be constructed with a resource template or InitModalIndirect
ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
m_lpDialogTemplate != NULL);
// load resource as necessary
LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
HGLOBAL hDialogTemplate = m_hDialogTemplate;
HINSTANCE hInst = AfxGetResourceHandle();
Any help appreciated!!