I am having problems with the Windows Service web browser. It tries to upload the username and password values ββto the site, but continues to fail and throws the following error:
System.InvalidCastException: Specified cast is not valid. at System.Windows.Forms.UnsafeNativeMethods.IHTMLDocument2.GetLocation() at System.Windows.Forms.WebBrowser.get_Document() at MyWindowsService.MyDataProcessor.login()
The code I use for this call is:
MyWebBrowser.Document.All["Login"].SetAttribute("Value", username); MyWebBrowser.Document.All["Password"].SetAttribute("Value", password); MyWebBrowser.Document.All["submit"].InvokeMember("Click");
Any ideas as to why he continues to fail? Thank you in advance.
source share