.NET/COM Exception with IRTDUpdateEvent

梦想的初衷 提交于 2019-12-11 05:40:04

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/7826528/net-com-exception-with-irtdupdateevent

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