I have a WebBrowser control on my page. To run javascript on the page displayed in the browser control, I call this.myBrowser.Document.InvokeScript ("Test");
This works in my dev block with IE7, but on a separate test machine, I get the following error:
Exception Type: System.InvalidCastException Message: Specified cast is not valid. Source: System.Windows.Forms Stack Trace: at System.Windows.Forms.UnsafeNativeMethods.IHTMLDocument2.GetLocation() at System.Windows.Forms.WebBrowser.get_Document() at InteriorHealth.EmbeddedBrowser.frmMain.CardRead(String strData) in E:\Develop\TestProject\frmMain.cs:line 265 at MyTest.frmMain.prtCardReader_DataReceived(Object sender, SerialDataReceivedEventArgs e) in E:\Develop\TestProject\frmMain.cs:line 355
IE6 is running on the test computer. Although I'm not sure, I assume that the cause of the errors is the difference in versions of IE. Does this sound right? How do I get around this?
Line 265 of the frmMain.cs file:
this.webKiosk.Document.InvokeScript(ConfigurationState.CardReader.Error.FireJavaScriptMethod);
Line 355 of the frmMain.cs file:
CardRead(strCardData_m);
I think the exception is thrown by calling the Document property of the WebBrowser object.
source share