IE对象中的RuntimeBinderException

本文关键字:RuntimeBinderException 对象 IE | 更新日期: 2023-09-27 17:54:46

首先,我应该说我需要在我的应用程序中使用Internet Explorer (IE9)对象,我不能使用webBrowser控件。因此,我想在网页上的字段上模拟焦点事件:

webBrowser.Document.Forms[0].GetElementsByTagName("input")[0].InvokeMember("onFocus");
webBrowser.Document.Forms[0].GetElementsByTagName("input")[0].SetAttribute("value", "aaaa");
webBrowser.Document.Forms[0].GetElementsByTagName("input")[1].InvokeMember("onFocus");
webBrowser.Document.Forms[0].GetElementsByTagName("input")[1].SetAttribute("value", "bbbbb");

webBrowser变量为public static SHDocVw.InternetExplorer webBrowser;。设置为"new SHDocVw.InternetExplorer();"
当执行第一行代码时,我得到一个异常,

"System.MarshalByRefObject.InvokeMember(<...>)" Inaccessible due to protection level.

我使用的函数是private static。也许这与IE的文档是动态的这一事实有关?
那么,我如何修复这个异常呢?或者是否有其他方法可以模拟专注于某个领域?

IE对象中的RuntimeBinderException

应该使用FireEvent()而不是InvokeMember()。

相关文章:
  • 没有找到相关文章