1

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.

Sam Goldberg
  • 6,711
  • 8
  • 52
  • 85

2 Answers2

4

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.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Thanks, Hans. I love the comment "It is best to chuck the machine and have it stop wasting everybody's time." I wish it where that easy. These are outside clients (not internal users)... But I think that will probably be the message I deliver (in more politic terms). – Sam Goldberg Apr 18 '12 at 13:48
  • Hi Hans - after reading your post, I checked the user's machine, and actually, he did have the registry entries for IRTDUpdateEvent and also the HKCR\TypeLib\{00020813-0000-0000-C000-000000000046} in the registry as well. The IRTDUpdateEvent\TypeLib\Version value was 1.5, and when I checked the HCKR\...\{0002...\1.5, it seemed to be in order - had subkeys with InteropAssembly and also win32 which looked in order. User is running Excel 2003. We are going to have him upgrade to 2007. Maybe it's an issue that we developed and compiled on machines using Excel 2007? – Sam Goldberg Apr 18 '12 at 14:45
  • IRTDUpdateEvent is only documented for Office 2007 so I can't predict what will happen when you try 2003. The type library version for 2007 is 1.6. You can waste more time with SysInternals' ProcMon utility, you'll see it searching for the type library. – Hans Passant Apr 18 '12 at 14:55
  • Hmmm... We developed this application initially against Excel 2003, and have many users running with that version. It seems that the problem was unique to this machine, or else the version of the installer we gave him. Do you know of any references that might explain version issues to be careful about when compiling against these interop assemblies? – Sam Goldberg Apr 18 '12 at 15:19
  • The user upgraded to Excel 2007 and that resolved the issue. He was previously running this component with Excel 2003 (on another machine). So the user's problem is resolved, although I would still like to clear up the version mystery. – Sam Goldberg Apr 18 '12 at 15:21
1

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

Community
  • 1
  • 1
tomasat
  • 578
  • 8
  • 11