AxWebBrowser create / dispose problem.

  • Thread starter Thread starter MARTIN LANNY
  • Start date Start date
M

MARTIN LANNY

On button1 click I create a browser like this:
Dim AxWebBrowser2 As New AxSHDocVw.AxWebBrowser

Then I navigate to url...
AxWebBrowser2.Navigate2(finalurl)

Then dispose it... like this:
Me.AxWebBrowser2.Dispose()



Next time a press button1, it doesn't work...
Gives me an error.

How do I re-create axwebbrowser after disposing it, so it doesn't give
me an error?

Martin
 
MARTIN,

For the webbrowser I always use the toolbox to get all dependencies from
that and drag it to a form and don't make it to small.

And than I don't dispose it. It has cost me to much time to succeed in that.

In addition, I have seen in this newsgroup, that I am not the only one for
that.

It is not for nothing that the behaviour will very much upgraded in the next
version.

I hope this helps?

Cor
 
This problem was all because no one could get axwebbrowser to refresh
properly.
I found this function:

Public Function GetPageHTML(ByVal URL As String, Optional ByVal
TimeoutSeconds As Integer = 10) As String
' Retrieves the HTML from the specified URL,
' using a default timeout of 10 seconds
Dim objRequest As Net.WebRequest
Dim objResponse As Net.WebResponse
Dim objStreamReceive As System.IO.Stream
Dim objEncoding As System.Text.Encoding
Dim objStreamRead As System.IO.StreamReader

Try
' Setup our Web request
objRequest = Net.WebRequest.Create(URL)
objRequest.Timeout = TimeoutSeconds * 1000
' Retrieve data from request
objResponse = objRequest.GetResponse
objStreamReceive = objResponse.GetResponseStream
objEncoding = System.Text.Encoding.GetEncoding( _
"utf-8")
objStreamRead = New System.IO.StreamReader( _
objStreamReceive, objEncoding)
' Set function return value
GetPageHTML = objStreamRead.ReadToEnd()
' Check if available, then close response
If Not objResponse Is Nothing Then
objResponse.Close()
End If
Catch
' Error occured grabbing data, simply return nothing
Return ""
End Try
End Function

To grab html code from the page and it is always a new and refreshed
page.
So this solved my troubles and because I do not have to use
axwebbrowser anymore, my application went down in size by 7 mb.
Amazing ...
Anyway, thanks for trying to help me.

Martin
 
Back
Top