title: CoCreateInstance fails with unknown error
body: <p>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. </p>
  
  <p>What could cause this problem?</p>
  
  <p>Please see the code below:</p>
  
  <pre><code>try
  {   
   CComPtr&lt;IDispatch&gt;  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-&gt;Write(CString("GetLastError : %u"), lasterror);
  logFile-&gt;Write(CString("HRESULT Value: %X"), hr);       
  }
  
  catch(CException *e)
  {     
  //Exception does not get caught in this catch
  
    LPSTR strError ="";
    e-&gt;GetErrorMessage(strError,MAX_PATH);        
    logFile-&gt;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-&gt;Write("COM ERROR2:"+CString(err2));
  CoUninitialize();
  }
  
  catch(...)
  {    
   //Exception get caught in this catch, Value returned is 0.
  
   logFile-&gt;Write("Unknown exception occurred:%X",  
                  HRESULT_FROM_WIN32(GetLastError()));        
   CoUninitialize();
  }
  </code></pre>