例如:
Webbrowser1.Document.DomDocument.Forms.Myform.mycontrol.Value = "test"
将使用多个Webbrowser控件实例失败
实际发生的是mycontrol对象变为Mycontrol并且编译后的vb.net应用程序将失败并出现错误
Member not found. (Exception from HRESULT: 0x80020003 (disP_E_MEMBERNOTFOUND))
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o,Type objType,
String name,Object[] args,String[] paramnames,Boolean[] copyBack)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance,
Type Type,String MemberName,Object[] Arguments,String[] ArgumentNames,
Type[] TypeArguments,Boolean[] copyBack)
at Execute() in C:\Projects\Webbrowser\SampleCall.vb:line 16
这个问题有什么解决方案吗?
解决方法
下一个作业将起作用:
Webbrowser1.Document.Forms("Myform").Children("mycontrol").InnerText = "test" Webbrowser1.Document.DomDocument.Forms("Myform").all("mycontrol").Value = "test" Webbrowser1.Document.DomDocument.Forms.Myform.all.mycontrol.Value = "test"
如果您使用反射器实用程序查看Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet方法,您会发现BindingFlags.IgnoreCase标志用于binder.InvokeMember调用.
我不知道这个调用是通过COM完成的,并且正在读取COM互操作在查找表中使用一个版本的名称的地方.就像参数名称最初作为“MyControl”输入到该表中一样,将使用此版本,而不是“mycontrol”.我想因为后来InvokeMember未能找到正确的成员.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。