This is probably due to an ASSERT in the code, and you will likely see this only on debug builds. You probably need to add:
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
before you call AfxGetResourceHandle(). Ask Google about AFX_MANAGE_STATE for more details.