AFX_MODULE_STATE not initialised - why ??? RRS feed

  • Question

  • My MFC application exe houses a COM object derived directly from CCmdTarget

    The application is started correct when the COM object is requested, InitInstance is enterered, but AFX_MODULE_STATE is not being initialised correctly.

    The client passes a filename across to the COM component and it then begins de-serialising the contents of this archive...

    When the MFC framework attempts to de-serialise the first class( its
    already de-serialised some CString and primitive types) it enters the
    following MFC method:

    CRuntimeClass* PASCAL CRuntimeClass::FromName(LPCSTR lpszClassName)
            CRuntimeClass* pClass=NULL;


            // search app specific classes
            AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
            for (pClass = pModuleState->m_classList; pClass != NULL;
                    pClass = pClass->m_pNextClass)
                    if (lstrcmpA(lpszClassName, pClass->m_lpszClassName) == 0)
                            return pClass;

    For whatever reason?  the pModuleState->m_classList is empty !!!!

    How does this get populated?
    Why would this be empty?

    Friday, November 17, 2006 2:02 PM