tags:

views:

177

answers:

2

Hi!

I have created a ActiveX control which works in all PCs except two on client's location. I have narrowed down the problem to failure of CoCreateInstance() which fails with unknown error.

What could cause this problem?

Please see the code below:

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();
}
A: 

It is almost certainly due to a missing dependency. Check registry to see if XBrowseInvokerBean.Bean and anything it relies upon is installed.

Mitch Wheat
A: 

How could i check dependency using registry? I use Dependency Walker to do this task.