I have been trying to use a few different ways of accessing documents on the web, trying to see if any of the methods are faster than others, and have been somewhat unsuccessful in a few of them. I say "somewhat", because even though I get errors, the operation does work. Here is the code I have been playing with. Comments on the errors following the code:
The errors occur in line 34 ( first statement in getSource() ), and in line 28 ( the first line in the Using block of the Button3 event ). The error in both cases is "A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll". In both cases, the operation completes, and the web page contents arrive just fine.
_HAWK_ will recognize the nifty little code to grab an IP address from a thread I was following.
Could mscorlib.dll be corrupted? There are a bunch of them in Windows\winsxs, for X84, WOW64 and X86, and I have no idea which one the code might be using.
Any ideas?
Option Strict On Option Explicit On Imports System.Diagnostics Imports System.Net Public Class Form1 Dim thread As System.Threading.Thread Dim sourcecode As String Dim sourceHtml As HtmlDocument Dim sw As New Stopwatch Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click sw.Reset() sw.Start() thread = New System.Threading.Thread(AddressOf GetSource) thread.Start() End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click sw.Reset() sw.Start() WebBrowser1.Navigate("http://lar3ry.comlu.com/weather/") Debug.Print(sw.Elapsed.ToString) End Sub Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click Using wb As New WebClient Dim s As String = wb.DownloadString("http://www.whatsmyip.us/showipsimple.php") MessageBox.Show(s) End Using End Sub Sub GetSource() Dim request As System.Net.WebRequest = System.Net.WebRequest.Create("http://lar3ry.comlu.com/weather/") Dim response As System.Net.WebResponse = request.GetResponse Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream()) sourcecode = sr.ReadToEnd() Debug.Print(sw.Elapsed.ToString) End Sub Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted Debug.Print(sw.Elapsed.ToString) sourceHtml = WebBrowser1.Document sourcecode = WebBrowser1.DocumentText End Sub End Class
The errors occur in line 34 ( first statement in getSource() ), and in line 28 ( the first line in the Using block of the Button3 event ). The error in both cases is "A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll". In both cases, the operation completes, and the web page contents arrive just fine.
_HAWK_ will recognize the nifty little code to grab an IP address from a thread I was following.
Could mscorlib.dll be corrupted? There are a bunch of them in Windows\winsxs, for X84, WOW64 and X86, and I have no idea which one the code might be using.
Any ideas?