.NET RTD/COM Excel Interop errors on one user's machine?

懵懂的女人 提交于 2019-12-23 02:19:38

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/10200154/net-rtd-com-excel-interop-errors-on-one-users-machine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!