Discussion:
Warning: Cannot load CRuntimeMap from archive. Class not defined.
(too old to reply)
Herby
2006-11-16 16:45:56 UTC
Permalink
My MFC application links to an static MFC class lib of our own classes.

When this application de-serializes its unable to resolve certain
classes and i get the following error:

Warning: Cannot load CRuntimeMap from archive. Class not defined.
CArchive exception: badClass.

So its like because my app is linking to a lib, certain object files
are not being included.

For a while i resolved this problem by providing a dummy function like
the following

void Calculator::LinkLibError()
{
CPWArithObjData arith;
CPWFilterObjData filter;
}

This seemed to force the linker to include the correct obj files.

Suddenly its started doing it for a class that is referenced directly
so applying the above solution does not work.

Can anybody throw some light on the problem?
Why would the linker fail to include the files when they are
referenced?
How can I force them to be included?

Or why would the internals of Serialize fail to find the name of a
class that should be loaded?

Thanks.
Herby
2006-11-17 10:26:33 UTC
Permalink
Can someone please help on this - im seriously baffled!

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;

ENSURE(lpszClassName);

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

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

How does this get populated?
Why would this be empty?
Herby
2006-11-17 15:42:55 UTC
Permalink
Guys, or anyone who has been following this - I think i may have solved
it.
A typical method of my COM class looks like this:

LONG COMCalculator::OpenOleFile(LPCTSTR strOleFilePath)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

bool result = mCalc.OpenOleFile(strOleFilePath);
if( result == true )
return S_OK;
return S_FALSE;
}



When i comment out AFX_MANAGE_STATE(AfxGetStaticModuleState())
It worked. I understand this is useful when your component is a DLL
and has resources.
As mine does not i do not need to call it.

Loading...