1
votes

We built a .NET COM/Excel RTD Server (.NET Assembly) which has been in use for many years, on a variety of machines (i.e. we know it works, and our standard method for installing it works). We have a user who installed this RTD component on a different machine, and is having problems getting it to function smoothly. I believe the problem relates to the Interop.Microsoft.Office.Interop.Excel.dll somehow being either incompatible with this machine, or else improperly registered. Here are specific details:

Although RTD links are working to some extent, we see this error frequently logged by our application:

RTDServer.NotifyExcel(): Error notifying Excel, ex=System.InvalidCastException: 
Unable to cast COM object of type 'System.__ComObject' to interface type 
'Microsoft.Office.Interop.Excel.IRTDUpdateEvent'. This operation failed because 
the QueryInterface call on the COM component for the interface with 
IID '{A43788C1-D91B-11D3-8F39-00C04F3651B8}' failed due to the following error: 
Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).     
 at Microsoft.Office.Interop.Excel.IRTDUpdateEvent.UpdateNotify()     
 at EZomsRTDServer.RTDServer.NotifyExcel()

When I was troubleshooting on the user's machine, I checked to see whether our component was registered in COM properly. We run this command to register our component with COM:

C:\EZomsRTD\regasm EZomsRTDServer.dll /codebase "c:\EZomsRTD\EZomsRTDServer.dll"
C:\EZomsRTD\regasm EZomsRTDServer.dll /tlb

Running these commands on user's machine produces this regasm error:

Type library exporter warning: Referenced type is defined 
in managed component, which is imported from a type library 
that could not be loaded because it was not registered 
(type: 'Microsoft.Office.Interop.Excel.IRtdServer'; component: 
'C:\EZomsRTD\Interop.Microsoft.Office.Interop.Excel.dll').  
Assembly exported to 'C:\EZomsRTD\EZomsRTDServer.tlb', and the type 
library was registered successfully

(The file: Interop.Microsoft.Office.Interop.Excel.dll is in the same folder as our component.)

Is this possibly caused by there being another version of the Interop.Excel assembly registered in this machine's GAC? Any other possible areas to investigate?

Note: User has Windows XP and Excel 2003. (Same profile as his previous machine which worked.)

Thanks in advance for any help.

2

2 Answers

4
votes

interface with IID '{A43788C1-D91B-11D3-8F39-00C04F3651B8}

That's the IRTDUpdateEvent interface. It indeed has an entry in HKCU\Interfaces that declares the standard marshaller. Which requires a type library, the LIBID is {00020813-0000-0000-C000-000000000046}.

What the error message is telling you is that the registry on that machine is missing the registry key HKCR\TypeLib\{00020813-0000-0000-C000-000000000046} or one of its subkeys. That could be because it has an old version of Office installed but that would be obvious. Just plain registry damage is the leading cause for such mishaps. It is best to chuck the machine and have it stop wasting everybody's time. Reinstall Office if that's unpractical for some reason. Trying to fix the registry key should be your last option, this kind of damage is rarely isolated.

1
votes

You may actually solve this issue by calling UpdateNotify on the same thread as Excel. See: https://stackoverflow.com/a/27006281/949779