建立的 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年的版本就沒有問題了。