Unable to cast COM object of type 'System.__ComObject' to class type 的解决办法
来源:互联网 发布:学长笛的软件 编辑:程序博客网 时间:2024/05/05 21:56
正在开发一个自动提交表单的程序,里面用到了WebBrowser控件。开始用这个控件时真是有点慌也是好奇,因为我对能够实现自动提交表单很感兴趣,开始不知如何下手。查了资料,里面说了一堆东西COM如何如何,让我头疼,毕竟我这种从开始就是用.net的程序员大多数对COM里面的不深刻。还好吧,总算克服很多困难做出来一些了。但是又在发布的时候遇到困难。奇怪的是在开发环境是正常的,这很让人认为是客户机器上少装了什么组件。
我遇到的具体错误是:
Unable to cast COM object of type 'System.__ComObject' to class type
'mshtml.HTMLDocumentClass'. COM components that enter the CLR and do not support
IProvideClassInfo or that do not have any interop assembly registered will be wrapped in the
__ComObject type. Instances of this type cannot be cast to any other class; however they can
be cast to interfaces as long as the underlying COM component supports QueryInterface calls
for the IID of the interface.
这段说的太啰嗦了,俺们英文不太好,理解起来还挺费劲的。
其实就是说对于COM对象,不能转化为类类型使用,而是要转化为其所继承的接口使用,就OK了!
果然,我把HTMLDocumentClass换为HTMLDocument(这是一个接口,尽管它的命名没有符合MS的命名规范)一切都正常了。
但是我心中尚有疑问没有解决:为什么我的开发环境上没有这个错误呢!?相信我对这个问题还是没有深入的理解,
如果您有一些见解!非常欢迎留言!谢谢!
- Unable to cast COM object of type 'System.__ComObject' to class type 的解决办法
- Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.E
- 【问题处理】Unable to cast object of type 'System.DBNull' to type 'System.String'.
- Unable to cast object of type 'System.Web.HttpApplication' to type 'Microsoft.Practices.CompositeWeb
- Unable to cast COM object of type 'Word.ApplicationClass' to interface type 'Word._Application'"
- 解决方法:Unable to cast COM object of type 'Shell32.ShellClass' to interface 'Shell32.IShellDispatch5'
- Unable to cast COM object of type Microsoft.Office.Interop.Excel.ApplicationClass' ...
- unable to cast object of type 'Microsoft.SharePoint.SPsite' to type 'Microsoft.SharePoint.SPWeb'
- Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory
- Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory
- struts 2学习(有关Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory的错误)
- struts 2学习(有关Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory的错误)
- struts 2学习(有关Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory的错误)
- struts 2学习(有关Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory的错误)
- struts 2学习(有关Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory的错误)
- Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory class:org.apache.struts2.spring.StrutsSpringObjectFactory - bean
- Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar
- Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar
- Error "Input Error: There is no script engine for file extension ".JS"
- WinXP下USB驱动开发(七)
- Tomcat 学习笔记
- 看看我们的进程强制结束
- SQLServer和Oracle常用函数对比
- Unable to cast COM object of type 'System.__ComObject' to class type 的解决办法
- 清除项目里的svn(或cvs)的小技巧
- C#实现自动发邮件
- Delphi2010中DataSnap高级技术(5)—建立稳定服务程序之TCP心跳包的使用
- 读李开复自传--世界因你而不同
- oracle 存储过程的基本语法 及注意事项
- ASP.NET 2.0发送电子邮件中存在的问题
- Adobe Flash平台服务 - 应用推广服务概览
- 非深户在深购买社保的好处与申请条件与流程