从字符串转换为双重无效仅适用于构建

时间:2014-02-02 00:36:09

标签: vb.net

好的,请注意,当我运行程序的构建版本时,会出现 ONLY - VB 2013中的调试器完全有效,但没有发现错误。在运行VB 2013的内置版本时,我收到了这个非常奇怪的错误。

enter image description here

由于这只发生在Visual Basics的一边,我无法正确调试错误。首先,为什么这只发生在Visual Basics的外面,我该如何防止它呢?

这是我的代码,在“下载完成”之后会显示错误消息。因此我不认为它与实际文件下载或初始互联网检查(ping)有关。

'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 个答案:

答案 0 :(得分:2)

我相信您的“生产”环境中App.config的RememberGamerTag为空白或缺失。

My.Settings返回的值通常是字符串。由于你的比较逻辑(My.Settings.RememberGamerTag = 1),VB.NET试图提供帮助并将后台转换为整数(Double),但空字符串导致它抛出异常。

为了保护自己免受这些错误的影响,请务必设置Option Strict