Edit

Using Microsoft Foundation Classes

Because of the footprint of statically linked DLLs, you should avoid using Microsoft Foundation Classes (MFCs) to write an expert. However, if you use the MFC, ensure access to any of the MFC DLL resources by including the following code immediately upon entry:

#ifdef _AFXDLL
      AFX_MANAGE_STATE(AfxGetStaticModuleState());
#endif