.NET RTD /上一个用户的计算机的COM互操作Excel的错误? [英] .NET RTD/COM Excel Interop errors on one user's machine?

查看:572
本文介绍了.NET RTD /上一个用户的计算机的COM互操作Excel的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们建立了一个.NET COM / Excel的RTD服务器(.NET程序集),其中已经使用了很多年,对各种机器(即,我们知道它的工作原理,以及我们对安装它的工作原理标法)。我们谁安装在不同的机器上这RTD组件的用户,并有得到它的顺利运作的问题。我认为这个问题涉及Interop.Microsoft.Office.Interop.Excel.dll某种程度上是要么与本机不兼容,或者注册不当。下面是具体的细节:

虽然RTD的链接工作在一定程度上,我们可以看到这个错误经常登录我们的应用程序:

  RTDServer.NotifyExcel():错误通知Excel中,EX = System.InvalidCastException:
无法转换类型的COM对象系统.__ ComObject'接口类型
Microsoft.Office.Interop.Excel.IRTDUpdateEvent。此操作失败的原因
COM组件调用QueryInterface与接口
IID{A43788C1-D91B-11D3-8F39-00C04F3651B8}'由于以下错误而失败:
库没有注册。 (从HRESULT异常:0x8002801D(TYPE_E_LIBNOTREGISTERED))。
 在Microsoft.Office.Interop.Excel.IRTDUpdateEvent.UpdateNotify()
 在EZomsRTDServer.RTDServer.NotifyExcel()
 

当我在排除故障的用户的机器上,我检查,看看我们的组件是否被注册COM正常。我们运行此命令与COM注册我们的组件:

  C:\ EZomsRTD \ regasm EZomsRTDServer.dll / codeBase的C:\ EZomsRTD \ EZomsRTDServer.dll
C:\ EZomsRTD \ regasm EZomsRTDServer.dll / TLB
 

在用户的计算机上运行这些命令产生此regasm错误:

 类型库导出警告:引用类型定义
在管理的组件,这是从一个类型库导入
不能被加载,因为它未注册
(类型:Microsoft.Office.Interop.Excel.IRtdServer';组件:
C:\ EZomsRTD \ Interop.Microsoft.Office.Interop.Excel.dll')。
大会导出到C:\ EZomsRTD \ EZomsRTDServer.tlb',类型
库已成功注册
 

(文件:Interop.Microsoft.Office.Interop.Excel.dll是在同一文件夹作为我们的组件)

难道这可能是由那里是另一个版本在本机的GAC注册的Interop.Excel组件造成的?任何其他可能的领域进行调查?

注:用户有Windows XP和Excel 2003的(相同的配置文件作为他开展工作的previous机)

在此先感谢您的帮助。

解决方案
  

与接口   IID{A43788C1-D91B-11D3-8F39-00C04F3651B8}

这就是IRTDUpdateEvent接口。它确实在HKCU \接口声明的标准编组的条目。这需要一个类型库的LIBID为{00020813-0000-0000-C000-000000000046}。

什么是错误信息,告诉你的是,该计算机上的注册表中缺少的注册表项 HKCR \类型库\ {00020813-0000-0000-C000-000000000046} 其子项或者一个。这可能是因为它有一个老版本的Office安装,但是这将是显而易见的。只是简单的注册表损坏是此类事故的主要原因。最好是夹紧机,并将它停止浪费大家的时间。重新安装Office如果这是不现实的某些原因。试图修复注册表项应该是你最后的选择,这种破坏是很少孤立的。

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.

解决方案

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.

这篇关于.NET RTD /上一个用户的计算机的COM互操作Excel的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆