When you export a function from a regular MFC DLL the function must include AFX_MANAGE_STATE.
For example,
extern "C" __declspec(dllexport) int CreateDlg()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CModeless* pdlg = new CModeless;
pdlg->Create(IDD_MODELESS);
pdlg->ShowWindow(SW_SHOW);
return 0;
}