Yaroslav Kazmin

Hi

I wrote small sample on VB.Net.

Empty form and one button. Click on button executes following piece of code:

Dim webBrowser1 As New WebBrowser

webBrowser1.Navigate("www.microsoft.com", "_BLANK")

I tested this sample on different computers, and on several computers it works perfect, but on other computers, it works only when no IE windows is opened. If I have IE window opened then computer doesn't response me and after some period of time I have an error:

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.InvalidCastException: Specified cast is not valid.
at System.Windows.Forms.UnsafeNativeMethods.IWebBrowser2.Navigate2(Object& URL, Object& flags, Object& targetFrameName, Object& postData, Object& headers)
at System.Windows.Forms.WebBrowser.PerformNavigate2(Object& URL, Object& flags, Object& targetFrameName, Object& postData, Object& headers)
at System.Windows.Forms.WebBrowser.PerformNavigateHelper(String urlString, Boolean newWindow, String targetFrameName, Byte[] postData, String headers)
at System.Windows.Forms.WebBrowser.Navigate(String urlString, String targetFrameName)
at IETest.Form1.Button1_Click(Object sender, EventArgs e)

Best regards

Yaroslav Kazmin



Re: Internet Explorer Extension Development WebBrowser.Navigate hang ups for 2 min and throws InvalidCastException

Yaroslav Kazmin

I forgot to mention I tested it on WinXP SP2 and IE 6.0 SP2

Thanks





Re: Internet Explorer Extension Development WebBrowser.Navigate hang ups for 2 min and throws InvalidCastException

John Sudds - MSFT

Usually, the targetFrameName argument is case-sensitive--try using "_blank" instead.

webBrowser1.Navigate("www.microsoft.com","_blank")

I am more familiar with the WebBrowser Object of SHDOCVW than the WebBrowser Class of System.Windows.Forms.

You might want to repost this question in the .NET forums for a larger audience.