无法转换Microsoft.Office.Interop.Word.ApplicationClass类型的com对象 [英] Unable to cast com object of type Microsoft.Office.Interop.Word.ApplicationClass
问题描述
我正在使用VS 2005和MS office 2003
_ Document oWordDoc = oWordApp.Documents.Open( ref fileName,
ref 缺失, ref readOnly,
ref 缺失, ref 缺失, ref 缺失,
参考缺失,参考缺失,参考缺失,
ref 缺失, ref 缺失, ref isVisible,
ref 缺失, ref 缺失, ref 缺失,参考缺失);
需要紧急帮助来整理
此时我收到错误:
无法将Microsoft.Office.Interop.Word.ApplicationClass类型的COM对象强制转换为接口类型'Microsoft .Office.Interop.Word._Application。此操作失败,因为由于以下错误,IID为{00020970-0000-0000-C000-000000000046}的接口的COM组件上的QueryInterface调用失败:不支持此类接口(HRESULT异常:0x80004002(E_NOINTERFACE)) 。
检查此帖子&继续寻找解决方案
C#Word自动化例外 [ ^ ]
但是基于部分错误消息(没有支持这样的接口(来自HRESULT的异常:0x80004002(E_NOINTERFACE))。
)我猜到了(通过以下线程),你需要修复MS Office 或需要重新注册相应的dll 。检查这个以获得详细说明(实际上下面的线程不是关于MS office但类似的类型[基于错误消息])所以试一试或等待上面MSDN链接中的答案
来自link1 大> [ ^ ]:问题已经解决了。
实际上,服务器操作系统是旧版本。所以我在bin文件夹中上传了旧版本的ADODB.dll,问题解决了。
=====解决方案== ===
经过一番调查,我发现注册表已经被破坏了,解决办法是重新注册DLL。
~运行[命令提示符](您需要使用**以管理员身份运行**选项) 还检查这些主题
......不支持此类接口(HRESULT异常:0x80004002(E_NOINTERFACE))。 [ ^ ]
哎呀!创建文档时出错 [ ^ ]
Im using VS 2005 and MS office 2003
_Document oWordDoc = oWordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
Need urgent help to sort out
At this I'm getting error as :
Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).解决方案Check this thread & keep looking there till the solution
C# Word Automation Exception[^]
But based on the partial error message(No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
) I got guesses(by the below threads), you need to repair the MS Office or need to re-register the appropriate dll. Check this for detailed explanation(Actually the below threads are not about MS office but similar type[based on error message]) so give it a try or wait for the answer in above MSDN link
From link1[^]:Problem has been solved out.
Actually, the server OS was of older version. So I uploaded the older version of ADODB.dll in bin folder and the problem got solved.
From link2[^]:===== Solution =====
After a bit of investigation, I found that the registry is somehow corrupted, and the solution is to re-register DLL.
~ Run [ Command Prompt ] (You will need to use the **Run as administrator** option)Also check these threads
...... No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).[^]
"Oops!" error when creating documents[^]
这篇关于无法转换Microsoft.Office.Interop.Word.ApplicationClass类型的com对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!