问题
I get this in the immediate window while debuging: A first chance exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll
Okay So I created a version checker to check if the version is correct else update. It is not working. It thinks the version is the same and doesn't update. It was working early and now it's randomly broken..
Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
'*update process
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://localhost/update/version.txt")
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
Dim newestversion As String = sr.ReadToEnd()
Dim currentversion As String = My.Settings.version
If newestversion.Contains(currentversion) Then
Label3.Text = "Up to date."
MsgBox("debug")
Button1.Enabled = True
Else
MsgBox("An new update is available! Please, do NOT close the launcher!", MsgBoxStyle.Information)
Label3.Text = "Updating game..."
Label3.Refresh()
GhostProgressbar1.Value = 10
'starts(download)
GhostProgressbar1.Value = +65
My.Computer.Network.DownloadFile("http://localhost/update/patch.zip", New System.IO.FileInfo(Application.ExecutablePath).DirectoryName + "/patch.zip")
GhostProgressbar1.Value = +15
'unzips update
Dim ZipToUnpack As String = "patch.zip"
Dim TargetDir As String = New System.IO.FileInfo(Application.ExecutablePath).DirectoryName
Console.WriteLine("Extracting file {0} to {1}", ZipToUnpack, TargetDir)
Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
Dim e1 As ZipEntry
For Each e1 In zip1
e1.Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently)
Next
End Using
'delete(zip)
GhostProgressbar1.Value = +9
My.Computer.FileSystem.DeleteFile(New System.IO.FileInfo(Application.ExecutablePath).DirectoryName + "/patch.zip")
GhostProgressbar1.Value = 100
My.Settings.version = newestversion
My.Settings.Save()
MsgBox("The game has been updated successfully!")
End If
Label3.Text = "Up to date."
Label3.Refresh()
Button1.Enabled = True
End Sub
来源:https://stackoverflow.com/questions/20157744/why-a-first-chance-exception-of-type-system-argumentexception-occurred-in-sys