新建的 ActiveX 控件工程,就算什么代码都不写进去,在连接时也会出现这样的问题;忽略断言错误继续下去,在Debug下生成了 .ocx文件,直接在运行对话框里输入: regsvr32 D:\ActiveX\debug\XXX.ocx (路径对的)也会出现同样的断言错误,不能注册;根据断言提示的错误去查找相关的错误 发现是红色部分的断言:
void CCmdTarget::EnableTypeLib()
{
AfxLockGlobals(CRIT_TYPELIBCACHE);
CTypeLibCache* pTypeLibCache = GetTypeLibCache();
ASSERT(pTypeLibCache != NULL); // must override GetTypeLibCache
if (pTypeLibCache != NULL)
pTypeLibCache->Lock(); // will be unlocked in OnFinalRelease
AfxUnlockGlobals(CRIT_TYPELIBCACHE);
}
到网上查找各种关于GetTypeLibCache();的信息也找不到,查看MFC的源码也找不到什么说明,没有办法,果断放弃看源码!!
结果今天不小心在MSDN上看到一个和我同样的例子:
When I try register control
regsvr32 CliControl.ocx
on some computersIhave"Debug Assertion Failed" in oletyplb.dll line 32
NOTE: On some computers... (WIN 2000 and XP)
According to oletyplb.cpp lines 31-32 are
CTypeLibCache* pTypeLibCache = GetTypeLibCache();
ASSERT(pTypeLibCache != NULL); // must override GetTypeLibCache
But I have no problems on other computers.
I check DLLs (that is listed in Dependency Walker) - all them are in System32 directory.
Has anybody some ideas?
--------------------------------------------------------------------------------
Jumpow04-07-2005, 12:38 PMPorlem is solved :-)
It is version of MFCO42D.DLL
原来:其实是 MFCO42D.DLL这个文件的版本问题,出问题的机器里的system32中的此文件为98年的版本,覆盖为04年的版本就没有问题了。