我创建了一个ActiveX控件,可以在除客户端位置的两台PC之外的所有PC上运行。我已经将问题缩小到CoCreateInstance()失败,并且失败并出现未知错误。
什么可能导致这个问题?
请参阅以下代码:
try
{
CComPtr<IDispatch> lpTDispatch;
//Following line generates an exception
HRESULT hr = lpTDispatch.CoCreateInstance(_bstr_t("XBrowseInvokerBean.Bean.1"));
//Following line do not get executed.
DWORD lasterror = GetLastError();
logFile->Write(CString("GetLastError : %u"), lasterror);
logFile->Write(CString("HRESULT Value: %X"), hr);
}
catch(CException *e)
{
//Exception does not get caught in this catch
LPSTR strError ="";
e->GetErrorMessage(strError,MAX_PATH);
logFile->Write("Exception:"+CString(strError));
CoUninitialize();
}
catch (_com_error e)
{
//Exception does not get caught in this catch
CString err2 = _com_error(HRESULT_FROM_WIN32(GetLastError())).ErrorMessage();
logFile->Write("COM ERROR2:"+CString(err2));
CoUninitialize();
}
catch(...)
{
//Exception get caught in this catch, Value returned is 0.
logFile->Write("Unknown exception occurred:%X",
HRESULT_FROM_WIN32(GetLastError()));
CoUninitialize();
}
答案 0 :(得分:0)
几乎可以肯定是由于缺少依赖性。检查注册表以查看是否安装了XBrowseInvokerBean.Bean
及其所依赖的任何内容。