无法转换类型为COM的对象 [英] Unable to cast COM object of type

查看:156
本文介绍了无法转换类型为COM的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在调试模式下运行代码时,出现以下错误..任何建议我该如何处理?谢谢

无法将类型为"Microsoft.Office.Interop.PowerPoint.ApplicationClass"的COM对象转换为类型为"Microsoft.Office.Interop.PowerPoint._Application"的接口.此操作失败,因为对IID为"{91493442-5A91-11CF-8700-00AA0060263B}"的接口的COM组件上的QueryInterface调用由于以下错误而失败:接口未注册(来自HRESULT的异常:0x80040155). > 

解决方案

无效的引用或对某些未注册程序集的引用都可能导致它.检查您是否引用了正确的Office Interop版本.


哪行会给您错误,您可以将其发布吗?


使用以下代码,可能会有所帮助你.

Microsoft.Office.Interop.PowerPoint.Application pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();

Presentation pptPresentation = pptApplication.Presentations.Open("bigstory.ppt", MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);


When I try to run the code in debug mode I get following error ..any suggestion how can i take care of it? thanks

Unable to cast COM object of type 'Microsoft.Office.Interop.PowerPoint.ApplicationClass' to interface type 'Microsoft.Office.Interop.PowerPoint._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{91493442-5A91-11CF-8700-00AA0060263B}' failed due to the following error: Interface not registered (Exception from HRESULT: 0x80040155).

解决方案

Invalid reference or reference to some unregistered assembly can cause it. Check if you are referencing correct version of Office Interop.


which line gives you error can you post it ?


Use following code, it might help you.

Microsoft.Office.Interop.PowerPoint.Application pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();

Presentation pptPresentation = pptApplication.Presentations.Open("bigstory.ppt", MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);


这篇关于无法转换类型为COM的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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