1. COM Exception on Write action (Library not registered)


Exception detail:

System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at Microsoft.Office.Interop.Excel._Application.get_ActiveSheet()
at SDM_ExcelClient.Core.Write.GetCurrentWorksheet()
at SDM_ExcelClient.Core.Write.WriteOnline()
   at SDM_ExcelClient.Core.Write.PerformWriteHandlingExceptions(Action action)


This can happen downgrading Excel from 2013 to 2010 on the host machine. The issue is related to a system registry inconsistency created by the downgrade.


To solve the issue, on the system registry (command regedit):

  1. Open registry key located in:
    • HKEY_CLASSES_ROOT\TypeLib\{000208D5-0000-0000-C000-000000000046}
    • HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}
    • HKEY_CLASSES_ROOT\TypeLib\{000C03A7-0000-0000-C000-000000000046}
  2. For each key, check if is present more then one version (1.7 is related to Excel 20101.8 is related to Excel 2013)
  3. If the key related to Excel 2013 (1.8) has no content, delete it.


2. Column added to form lowest table, using check physical layer, doesn't appear.

  1. Make sure the new column is visibile in the form
  2. Close all running Excel applications
  3. Open a new Excel instance
  4. Read the form
  5. Make sure there is no template associated to the form, that could overwrite the column. Please see Overview of XML in Excel