ActiveX控件初始化失败,COleControl::InitializeIIDs中断了程序
编写一个ActiveX控件,用VC自带的容易测试时,程序中断到COleControl::InitializeIIDs函数中的一个位置,该函数内容如下:
void COleControl::InitializeIIDs(const IID* piidPrimary, const IID* piidEvents)
{
m_piidPrimary = piidPrimary;
m_piidEvents = piidEvents;
EnableTypeLib();
// Initialize the masks for stock events and properties.
InitStockEventMask();
InitStockPropMask();
#ifdef _DEBUG
// Verify that the type library contains all the correct information.
// If any of the following assertions fail, carefully check the IDs
// in the control's .CPP file against those in its .ODL file.
LPTYPEINFO pTypeInfo;
HRESULT hr;
CLSID clsid;
GetClassID(&clsid);
if (SUCCEEDED(hr = GetTypeInfoOfGuid(0, clsid, &pTypeInfo)))
RELEASE(pTypeInfo);
ASSERT(SUCCEEDED(hr)); // Class ID may be corrupted
if (SUCCEEDED(hr = GetTypeInfoOfGuid(0, *m_piidPrimary, &pTypeInfo)))
RELEASE(pTypeInfo);
ASSERT(SUCCEEDED(hr)); // Primary dispatch interface ID may be corrupted
if (SUCCEEDED(hr = GetTypeInfoOfGuid(0, *m_piidEvents, &pTypeInfo)))
RELEASE(pTypeInfo);
ASSERT(SUCCEEDED(hr)); // Event dispatch interface ID may be corrupted
#endif
}
中断的位置是第一个ASSERT函数处,请问这个问题产生的原因,如何解决,多谢高手
[解决办法]
ASSERT(SUCCEEDED(hr)); // Class ID may be corrupted