我们在各种机器上(即我们知道它的工作原理以及我们的标准安装方法)建立了一个已在使用多年的.NET COM/Excel RTD服务器(.NET程序集)。我们有一个用户在不同的机器上安装了这个RTD组件,并且在顺利运行时遇到了问题。我相信这个问题与Interop.Microsoft.Office.Interop.Excel.dll有关,或者与这台机器不兼容,或者不正确的注册。下面是具体的细节:一台用户机器上的.NET RTD/COM Excel Interop错误?
虽然RTD链接工作在一定程度上,我们可以看到这个错误经常被我们的应用程序登录:
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()
当我在用户的计算机上排除故障,我检查,看看是否我们组件已在COM中正确注册。我们运行这个命令与COM注册我们的组件:
C:\EZomsRTD\regasm EZomsRTDServer.dll /codebase "c:\EZomsRTD\EZomsRTDServer.dll"
C:\EZomsRTD\regasm EZomsRTDServer.dll /tlb
运行用户计算机上的这些命令产生这个错误regasm:
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
(文件:Interop.Microsoft.Office.Interop.Excel。 dll与我们的组件位于同一文件夹中。)
这可能是由于在本机的GAC中注册了另一个版本的Interop.Excel程序集引起的?任何其他可能的领域进行调查?
注:用户有Windows XP和Excel 2003中提前任何帮助
感谢(相同的轮廓。他以前的机器,其工作)。
谢谢,汉斯。我喜欢这样的评论:“最好是去查机器,不要浪费每个人的时间。”我希望它在那里容易。这些是外部客户(不是内部用户)......但我认为这可能是我提供的信息(更具政治意义)。 – 2012-04-18 13:48:03
您好汉斯 - 在阅读您的文章后,我检查了用户的机器,实际上,他确实有注册表中的IRTDUpdateEvent以及HKCR \ TypeLib \ {00020813-0000-0000-C000-000000000046}的注册表项。 IRTDUpdateEvent \ TypeLib \ Version值为1.5,当我检查HCKR \ ... \ {0002 ... \ 1.5时,它似乎是按顺序的 - 具有InteropAssembly的子项以及按顺序查看的win32。用户正在运行Excel 2003.我们将让他升级到2007年。也许这是我们在使用Excel 2007的计算机上开发和编译的问题? – 2012-04-18 14:45:24
IRTDUpdateEvent仅为Office 2007记录,因此我无法预测尝试2003时会发生什么。2007年的类型库版本为1.6。您可以使用SysInternals的ProcMon实用程序浪费更多时间,您会看到它搜索类型库。 – 2012-04-18 14:55:19