0

Okay, please note that this ONLY happens when I run the build version of the program - the debugger in VB 2013 completely works but doesn't pick up on the error. Upon running the built version out-side of VB 2013 I receive this really strange error.

enter image description here

As this only happens out side of Visual Basics I'm unable to properly debug the error. Firstly, why is this only happening out-side of Visual Basics and how can I prevent it?

Here's my code, the error message appears after the 'Download Complete' line so I don't think it has anything to do with the actual file downloads or the initial internet check (pings).

'Test for Internet Connectivity 
    loginstat.Text = "Confirming Internet Connection..."
    My.Application.DoEvents()
    Try
        If My.Computer.Network.Ping("www.google.com") = True Then
            loginstat.Text = "Internet Connection Confirmed."
            My.Application.DoEvents()
        Else
            loginstat.Text = "Internet Connection Failed."
            My.Application.DoEvents()
            MessageBox.Show("Whoops! I was unable to connect to the internet. Please check your network connection. You may have to add this program to the 'Trusted Applications' list of your firewall.", "Offline Mode")
            End
        End If
    Catch ex As Exception
        MessageBox.Show("Whoops! I was unable to connect to the internet. You may have to add this program to the 'Trusted Applications' list of your firewall. " & _
                       vbNewLine & "" & vbNewLine & String.Format("Error: {0}", ex.Message))
        loginstat.Text = "Internet Connection Failed."
        End
    End Try


    Try
        loginstat.Text = "Downloading Server Credentails. Please wait..."
        My.Application.DoEvents()
        serveriptxt.Text = GetRemoteFile("https://dl.dropboxusercontent.com/s/qzw2etb094k6h8z/DataBase-IP.txt?dl=1&token_hash=A***")
        databaseusertxt.Text = GetRemoteFile("https://dl.dropboxusercontent.com/s/m9qitkq9lupi19b/DataBase-User.txt?dl=1&token_hash=AAGxkgmmW****")
        My.Settings.RegisterKey = GetRemoteFile("https://dl.dropboxusercontent.com/s/dtts45fnplyh4ma/DataBase-RegisterKey.txt?dl=1&token_hash=AAF****")
        My.Settings.AccessCode = GetRemoteFile("https://dl.dropboxusercontent.com/s/iuaz4kig5pidzmw/DataBase-AccessCode.txt?dl=1&token_hash=AAHgWc9***")
        My.Settings.Save()
        loginstat.Text = "Downloading Complete."
        My.Application.DoEvents()
        TabControl1.Enabled = True

        If My.Settings.RememberGamerTag = 1 Then
            RememberGamerTag.Checked = True
            LogUsername.Text = My.Settings.UserGamerTagRemember
        End If

        loginstat.Text = "Ready."

    Catch ex As Exception
        MessageBox.Show("Whoops! I was unable to download the server credentials, this is likely a network problem on your PC. Please check your network connection & firewall configuration. You may have to add this program to the 'Trusted Applications' list of your firewall. " & _
                       vbNewLine & "" & vbNewLine & String.Format("Error: {0}", ex.Message))
        loginstat.Text = "Server Credentails Failed."
    End Try
1
  • 2
    You could handle this ecxeption and log the complete stacktrace. stackoverflow.com/a/10203030/284240 I assume that Application.DoEvents() executes code that causes this exception. Commented Feb 2, 2014 at 0:53

1 Answer 1

2

I believe the RememberGamerTag of your App.config is blank or missing in your "production" environment.

Values returned by My.Settings are typically strings. VB.NET is trying to be helpful and doing a background conversion to an integer (Double) because of your comparison logic (My.Settings.RememberGamerTag = 1), but the empty string is causing it to throw an Exception.

To protect yourself from these kinds of errors in the future, be sure to set Option Strict on.

Sign up to request clarification or add additional context in comments.

5 Comments

That's defaulted to 1 in the Projects Settings.
So is it configured as an Intger? Then it's default is 0 if you don't provide a default value.
Hi, I removed the section that yous are referring to and rebuilt my program, the error is still happening. So it must be something else...
My appologize, there was a similar section of code doing exactly the same thing with a different setting, that was not set to an integer. Thank you for your help.
@user3224987 Use Option Strict in the future to prevent these kinds of run-time errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.