Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IE对象中的RuntimeBinderException_C#_Internet Explorer 9 - Fatal编程技术网

C# IE对象中的RuntimeBinderException

C# IE对象中的RuntimeBinderException,c#,internet-explorer-9,C#,Internet Explorer 9,首先,我应该说我需要在我的应用程序中使用Internet Explorer(IE9)对象,我不能使用webBrowser控件。因此,我想在网页的某个字段上模拟焦点事件: webBrowser.Document.Forms[0].GetElementsByTagName("input")[0].InvokeMember("onFocus"); webBrowser.Document.Forms[0].GetElementsByTagName("input")[0].SetAttribute("va

首先,我应该说我需要在我的应用程序中使用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变量是
公共静态SHDocVw.InternetExplorer webBrowser。其值设置为
new SHDocVw.InternetExplorer()
当代码的第一行被执行时,我得到一个异常

"System.MarshalByRefObject.InvokeMember(<...>)" Inaccessible due to protection level.
“System.MarshallByRefObject.InvokeMember()”由于保护级别而无法访问。
我使用的函数是
private static
。也许这与IE的文档是动态的这一事实有关?
那么,如何修复此异常?或者有没有其他方法可以模拟某个领域的焦点?
提前感谢。

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