Synchronization error "Unable to cast COM object"

Description

The synchronization of eWay-CRM is not working. The log shows this message:

HASH: C476D5BB13FF545630119FA1D81268D8
Synchronization failed
System.InvalidCastException: Unable to cast COM object of type Microsoft.Office.Interop.Outlook.ApplicationClass to interface type Microsoft.Office.Interop.Outlook._Application. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063001-0000-0000-C000-000000000046} failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
   v Microsoft.Office.Interop.Outlook.ApplicationClass.get_Version()
   v eWay.Core.OutlookAccess.Application..ctor(Application application)
   v eWay.Core.OutlookAccess.Application..ctor()
   v eWay.StandardEdition.Synchronization.SynchronizeThread.SynchronizeAll(IEnumerable`1 folders, Boolean& synchronizationOK, Boolean& newData, DateTime till)
   v eWay.StandardEdition.Synchronization.SynchronizeThread.Synchronize()
--- END TRACE ---

This error can also appear:

HASH: 9A28D348A685DDE9EC282BEE1F817FE3
Synchronization failed
System.InvalidCastException: Unable to cast COM object of type 'Microsoft.Office.Interop.Outlook.ApplicationClass' to interface type 'Microsoft.Office.Interop.Outlook._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063001-0000-0000-C000-000000000046}' failed due to the following error: Knihovna není zaregistrována. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
   at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
   at Microsoft.Office.Interop.Outlook.ApplicationClass.get_Version()
   at eWay.Core.OutlookAccess.Application..ctor(Application application)
   at eWay.Core.OutlookAccess.OutlookApplicationManager.get_Instance()
   at eWay.Core.Synchronization.SynchronizeThread.SynchronizeObjectTypes()
   at eWay.Core.Synchronization.SynchronizeThread.CreateDatabaseStructure()
--- END TRACE ---

Version

All versions of eWay-CRM

Difficulty

High

Resolution

This is not an error caused by eWay-CRM, but an error caused by Microsoft Office. It can appear due to this operations:

  1. You had Microsoft Office 2010 and you replaced it by Microsoft 2007.
  2. You installed Microsoft Office 2007 and separately you installed an application from Microsoft Office 2010 (or the other way around).

Option 1: Incorrect key in Windows Registry

You need to check keys in the Microsoft Windows Registry. Follow these steps:

  1. In the Registry Editor (search regedit in the Start menu), go through the path HKEY_CLASSES_ROOT\TypeLib\{00062FFF-0000-0000-C000-000000000046}
  2. There should be more than one version, so there are branches also for the newer versions even though you use older version of Microsoft Office. You need to erase the newer version.
  3. Newer version can be recognized by the text Microsoft Outlook XX.0 Object Library right next to the key. Erase the key with the higher version (the version is a number instead of XX). In the example the value to be deleted is 9.6.

Option 2: Correct key in Windows Registry

In the case you have only one key in the Microsoft Windows Registry, you need to repair Microsoft Office. For the repair, please use this article.