我遇到了一些问题,涉及到Windows Service中的webbrowser对象。它试图加载用户名和密码到一个网站,但是一直失败并抛出以下错误:
System.InvalidCastException:指定的强制转换无效。 在System.Windows.Forms.UnsafeNativeMethods.IHTMLDocument2.GetLocation() 在System.Windows.Forms.WebBrowser.get_Document() 在MyWindowsService.MyDataProcessor.login()
我用于进行此调用的代码是:
有什么想法是为什么它一直失败吗?感谢提前帮助。
System.InvalidCastException:指定的强制转换无效。 在System.Windows.Forms.UnsafeNativeMethods.IHTMLDocument2.GetLocation() 在System.Windows.Forms.WebBrowser.get_Document() 在MyWindowsService.MyDataProcessor.login()
我用于进行此调用的代码是:
MyWebBrowser.Document.All["Login"].SetAttribute("Value", username);
MyWebBrowser.Document.All["Password"].SetAttribute("Value", password);
MyWebBrowser.Document.All["submit"].InvokeMember("Click");
有什么想法是为什么它一直失败吗?感谢提前帮助。