Forum Discussion

LiamM's avatar
LiamM
Experienced User
1 year ago

Error Connecting Windows App to MYOB

 

As of today several users are reporting issues with connections from our windows application to MYOB. 

 

I believe it is related to the underlying use of Internet Explorer as a part of the embedded web browser in the application.  I can also see another client has reported exactly the same issue.  As far as I am aware, this issue has only started today.  It appears something has changed in the MYOB web pages that IE does not like.

65 Replies

  • The_Doc's avatar
    The_Doc
    Ultimate Cover User
    1 year ago

    Hi Folks

    I have just uploaded the WebViewer2 browser wrapper for Access - an ActiveX control - added it to my code that has worked for 5 years plus - and using the new ActiveX screen tried to get my Authentication Code with my initial GET call that is erroring on a chrome/edge browser.

    My MYOB logon popped up - I authenticated, it asked me to ALLOW ACCESS - then an error page came up - don't know the payload but suspect same error as direct post to chrome or edge browser.

    Haven't quite worked out AntView2 - its obj controls are very different from the original control - so I haven't captured the return from MYOB but 

     

    Here it is - seems like running up a VB.Net program likely produce the same error - MYOB's lic server is giving out the wrong Authorisation Codes to some people.

     

    The Doc

  • Hi All,
    I've been working though this for several days and I've built a test app (i've built this using example code from the community) using the WebView2 package and still no luck.

    Even when I try using Edge I still get an error message as below:

    Other times I get and IP Address error message.

    I'm trying this on my Dev and other device with the same results, the best I've had so far is edge in that it gave me back a code.

     

    I have tried my test app and I've only ever got back a response with the code in it and off course it had an error.

    Below is the code for the form as I can't add the project files....

    Imports Microsoft.Web.WebView2.Core
    Imports System.IO

    Public Class frmWebView
        Private Async Sub frmWebView_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            txtURL.Text = "https://www.google.com.au"
            LogMsg($"MS Edge Version: {CoreWebView2Environment.GetAvailableBrowserVersionString()}")
            '   Initialise.
            Await wvwMain.EnsureCoreWebView2Async()
            'Await InitializeCoreWebView2Async(Path.Combine("C:\Temp", Reflection.Assembly.GetExecutingAssembly().GetName().Name))

            If Not String.IsNullOrEmpty(txtURL.Text) Then
                '   Navigate to URL.
                WebsiteNavigate(txtURL.Text)
            End If
        End Sub

        Private Sub frmWebView_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
            '   Unsubscribe from CoreWebView2 event(s) (remove event handlers).
            RemoveHandler wvwMain.CoreWebView2.HistoryChanged, AddressOf wvwMain_HistoryChanged
        End Sub

        Private Sub txtURL_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtURL.KeyPress
            '// Press ENTER
            If Asc(e.KeyChar) = 13 Then
                '// No beep
                e.Handled = True
                Try
                    'wvwMain.CoreWebView2.Navigate(txtURL.Text)
                    '// Or --> wvwMain.CoreWebView2.Navigate(txtURL.Text)
                    wvwMain.Source = New Uri(txtURL.Text)
                Catch ex As UriFormatException
                    MessageBox.Show("The URL must be fully styled, such as the prefix. http[s]://")
                Catch ex As Exception
                    MessageBox.Show($"Error: {ex}")
                End Try
            End If
        End Sub

        Private Sub wvwMain_CoreWebView2InitializationCompleted(sender As Object, e As CoreWebView2InitializationCompletedEventArgs) Handles wvwMain.CoreWebView2InitializationCompleted
            LogMsg("wvwMain_CoreWebView2InitializationCompleted")
            LogMsg($"UserDataFolder: {wvwMain.CoreWebView2.Environment.UserDataFolder.ToString()}")
            '   Subscribe to CoreWebView2 event(s) (add event handlers).
            AddHandler wvwMain.CoreWebView2.HistoryChanged, AddressOf wvwMain_HistoryChanged
        End Sub

        Private Sub wvwMain_NavigationCompleted(sender As Object, e As CoreWebView2NavigationCompletedEventArgs) Handles wvwMain.NavigationCompleted
            MessageBox.Show(wvwMain.Source.ToString())
            LogMsg("wvwMain_NavigationCompleted")
        End Sub

        Private Sub wvwMain_WebMessageReceived(sender As Object, e As CoreWebView2WebMessageReceivedEventArgs) Handles wvwMain.WebMessageReceived
            LogMsg("wvwMain_WebMessageReceived")
        End Sub

        Private Async Function InitializeCoreWebView2Async(Optional userDataFolder As String = "") As Task
            Dim options As CoreWebView2EnvironmentOptions = Nothing
            Dim cwv2Environment As CoreWebView2Environment = Nothing

            '   It's recommended to create the userDataFolder in the same location
            '   that your other application data is stored (ie: in a folder in %APPDATA%)
            '   if not specified, we'll create a folder in %TEMP%
            If String.IsNullOrEmpty(userDataFolder) Then
                userDataFolder = Path.Combine(Path.GetTempPath(), Reflection.Assembly.GetExecutingAssembly().GetName().Name)
            End If

            '   Create WebView2 Environment using the installed or specified WebView2 Runtime version.
            'cwv2Environment = Await CoreWebView2Environment.CreateAsync("C:\Program Files (x86)\Microsoft\Edge Dev\Application\1.0.1054.31", userDataFolder, options)
            cwv2Environment = Await CoreWebView2Environment.CreateAsync(Nothing, userDataFolder, options)
            '   Initialise.
            Await wvwMain.EnsureCoreWebView2Async(cwv2Environment)
        End Function

        Private Sub wvwMain_HistoryChanged(sender As Object, e As Object)
            LogMsg("wvwMain_HistoryChanged")
            'btnBack.Enabled = WebView21.CoreWebView2.CanGoBack
            'btnForward.Enabled = WebView21.CoreWebView2.CanGoForward
            '   Update the Address Bar.
            UpdateAddressBar()
        End Sub

        Private Sub LogMsg(msg As String, Optional addTimestamp As Boolean = True)
            If addTimestamp Then
                msg = $"{Now.ToString("yyyy/MM/dd HH:mm:ss.fff")} - {msg}"
            End If

            Debug.WriteLine(msg)
        End Sub

        Private Sub UpdateAddressBar()
            ''   If necessary, update address bar.
            'If textBoxAddressBar.Text <> wvwMain.Source.ToString() Then
            '    textBoxAddressBar.Text = wvwMain.Source.ToString()

            '    'move cursor to end of text
            '    textBoxAddressBar.SelectionStart = textBoxAddressBar.Text.Length
            '    textBoxAddressBar.SelectionLength = 0
            'End If
        End Sub

        Private Sub WebsiteNavigate(ByVal dest As String)
            If wvwMain IsNot Nothing AndAlso Not String.IsNullOrWhiteSpace(dest) Then
                '   URL must start with one of the specified strings
                '   if Not, pre-pend with "https://"
                If Not dest = "about:blank" AndAlso Not dest.StartsWith("edge://") AndAlso
                   Not dest.StartsWith("file://") AndAlso Not dest.StartsWith("http://") AndAlso
                   Not dest.StartsWith("https://") AndAlso
                   Not System.Text.RegularExpressions.Regex.IsMatch(dest, "^([A-Z]|[a-z]):") Then
                    '   Set Value
                    dest = "https://" & dest
                End If

                '   Option 1.
                'wvwMain.Source = New Uri(dest, UriKind.Absolute)
                '   Option 2.
                wvwMain.CoreWebView2.Navigate(dest)
                '   Update the Address Bar.
                UpdateAddressBar()
            End If
        End Sub
    End Class


    Please let me know what I am doing wrong here.

  • The_Doc's avatar
    The_Doc
    Ultimate Cover User
    1 year ago

    Hi Phil_Jeffrey_KC 

     

    Thanks for the information - I just didn't know the methods that came with Antview2 - very different from Access web browser - so was manually posting and on error page - Right clicking page but no "source" - so manually processed the above line = code as a legit Access Code and finally this morning the returned tokens were correct.

     

    Now to sort out all my code - appreciate you code posted - will be very helpful - just don't need to lose time getting going - If I can just get my 7d Refresh I don't need anything more except to Refresh to work.

     

    Hopefully all will work.

     

    Regards The Doc

     

     

  • DevRBSystems's avatar
    DevRBSystems
    Member
    1 year ago

    Hi All,

    Thanks for all the support and help with this, I've finally got it working.

     

    I've moved the code from my test harness into our live app and our customers are finally syning again.

     

    This hasn't been a pleasant experience with MYOB on this.

    Cheers

    A.

  • Trish_Lee's avatar
    Trish_Lee
    Experienced User
    1 year ago

    Hi Mike_MYOB 

    I also would like to highlight the brilliant support from Steve_PP  who was amazingly generous with providing source code that enable us to complete the changes for our app.

    The developers on this forum, who have provided their knowledge to assist others is what a really good community is about.

     

    Thanks

    Trish