Results 1 to 2 of 2

Thread: App Ignores All Nav Commands Post NavError

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    1

    App Ignores All Nav Commands Post NavError

    Hoping someone here can help with this problem -

    I am running an AxWebBrowser with a proxy server connection to reach the internet. However, after a navigation error event, the application ignores all further navigate commands. When not connecting through a proxy, the code works fine. Here's the main code:

    Code:
            RefreshIESettings("216.120.33.31:3128") 'Working proxy picked off the web, have tried different proxies
            WebBrowser1.Navigate("www.fiali3kskfjls.com") 'Intentional Navigate Error
    
            While WebBrowser1.ReadyState < SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE
                Application.DoEvents()
            End While
    
            WebBrowser1.Navigate("www.google.com") 'For some reason, this command is ignored

    Here's the proxy code from Rodger
    Code:
      'PROXY CODE
        ' The structure we use for the information
        ' to be interpreted correctly by API.
        Public Structure Struct_INTERNET_PROXY_INFO
            Public dwAccessType As Integer
            Public proxy As IntPtr
            Public proxyBypass As IntPtr
        End Structure
    
        ' The Windows API function that allows us to manipulate
        ' IE settings programmatically.
        Private Declare Auto Function InternetSetOption Lib "wininet.dll" _
        (ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, _
         ByVal lpdwBufferLength As Integer) As Boolean
    
        ' The function we will be using to set the proxy settings.
        Private Sub RefreshIESettings(ByVal strProxy As String)
            Const INTERNET_OPTION_PROXY As Integer = 38
            Const INTERNET_OPEN_TYPE_PROXY As Integer = 3
            Dim struct_IPI As Struct_INTERNET_PROXY_INFO
    
            ' Filling in structure
            struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY
            struct_IPI.proxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(strProxy)
            struct_IPI.proxyBypass = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("local")
    
            ' Allocating memory
            Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))
    
            ' Converting structure to IntPtr
            System.Runtime.InteropServices.Marshal.StructureToPtr(struct_IPI, intptrStruct, True)
            Dim iReturn As Boolean = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))
        End Sub

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: App Ignores All Nav Commands Post NavError

    Generally you should just handle the DocumentCompleted event which fires when a page has finished loading, not loop with DoEvents and wait for a ready state.

    If the navigation after your doevents loop never fires, I would say it is a safe guess that the browser never reaches an state of SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE when your code runs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width