.NET/COM IRTDUpdateEvent 异常
我们构建了一个 RTD 服务器组件,该组件已广泛使用多年。 (它是使用 VS 2008、.NET 3.5 Target Runtime 构建的。)今天,一位用户报告遇到以下异常:
System.InvalidCastException:无法转换类型的 COM 对象 “System.__ComObject”到接口类型 'Microsoft.Office.Interop.Excel.IRTDUpdateEvent'。这个操作 失败,因为对 COM 组件的 QueryInterface 调用 由于 IID“{A43788C1-D91B-11D3-8F39-00C04F3651B8}”的接口失败 出现以下错误:不支持此类接口(异常来自 HRESULT:0x80004002(E_NOINTERFACE))。在 Microsoft.Office.Interop.Excel.IRTDUpdateEvent.UpdateNotify() 位于 EZomsRTDServer.RTDServer.NotifyExcel()
他昨天运行良好。该问题似乎是由于他安装了新应用程序而导致他安装 .NET 4 更新。 (他已经安装了.NET 4,所以不确定这个更新是什么。)用户通过回滚到昨天的还原点(仍然运行.NET 4)解决了问题。但我们需要了解安装过程中可能发生的情况导致 COM 兼容性问题。 (他没有接触 Excel 或我们的 RTD 应用程序)。
有可能其中一个安装使用了 IRTDUpdateEvent 的 Guid 来表示其他 COM 类吗?
We built an RTD Server assembly which has been in wide use for several years. (It was built with VS 2008, .NET 3.5 Target Runtime.) Today a user reported getting the following Exception:
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: No such interface supported (Exception from
HRESULT: 0x80004002 (E_NOINTERFACE)). at
Microsoft.Office.Interop.Excel.IRTDUpdateEvent.UpdateNotify() at
EZomsRTDServer.RTDServer.NotifyExcel()
He was running fine yesterday. The problem seems to have been caused by him installing a new application which prompted him to install an .NET 4 update. (He already had .NET 4 installed, so not sure what this update was.) The user resolved the problem by rolling back to yesterday's restore point (which still was running .NET 4). But we need to understand what could have happened during an install to cause the COM compatibility problem. (He didn't touch Excel or our RTD application).
Could it be possible that one of the installs used the Guid of the IRTDUpdateEvent for some other COM class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您收到此错误的原因可能是因为您在 Excel 所在线程以外的线程上调用 UpdateNotify。
http://weblogs.asp.net/kennykerr/Rtd8
解决这个问题的一个好方法是此处描述。
https://stackoverflow.com/a/24422419/949779
I think the reason you may be getting this error is because you are calling UpdateNotify on a thread other than the one Excel is on.
http://weblogs.asp.net/kennykerr/Rtd8
A good way to solve this is described here.
https://stackoverflow.com/a/24422419/949779
这在另一篇文章中得到了回答:
一台用户计算机上的 .NET RTD/COM Excel 互操作错误?
问题似乎在于使用 Excel 2003 的计算机创建此 COM 对象的方式与使用 Excel 2007 的计算机创建该 COM 对象的方式之间的差异。
This was answered in another post:
.NET RTD/COM Excel Interop errors on one user's machine?
The problem seems to have been differences between how a machine with Excel 2003 was creating this COM object, versus how a machine with Excel 2007 was creating it.