Ich will mein Programm auf Updates überprüfen lassen. Habe dazu dies fertig gemacht.
leider zeigt er mir immer "objektverweis wurde nicht auf eine objektinstanz festgelegt" ... verstehe nur nicht ganz wo der fehler liegt wenn ich die Links anklicke, ist alles richtig.
Danke im vorraus.
VB.NET-Quellcode
- Private web As System.Net.WebClient
- Private VersionsFilePath As String = "http://***/Programme/***application/version.txt" & "?dl=1"
- Private UpdateDownloadPath As String = "http://***/Programme/***application/***application.exe" & "?dl=1"
- Private SaveFileName As String = Application.StartupPath & "\update.exe"
- Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles Me.Shown
- If Not IsExecutedInIDE() Then CheckForUpdate()
- End Sub
- Private Sub CheckForUpdate()
- If TestInternetConnection() Then
- Try
- Dim version As String = web.DownloadString(VersionsFilePath)
- version = CInt(version)
- If version > CInt(lbl_version.Text) Then
- web.DownloadFile(UpdateDownloadPath, SaveFileName)
- MessageBox.Show("Ein Neues Update ist Verfügbar, es wird nun Installiert. Das Programm startet gleich neu.", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
- Process.Start("update.bat")
- Application.Exit()
- End If
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- End Try
- Else : MessageBox.Show("Keine Internetverbindung")
- End If
- End Sub
- Private Function TestInternetConnection() As Boolean
- Try
- Dim ping As New System.Net.NetworkInformation.Ping()
- ping.Send("google.de")
- Return True
- Catch ex As Exception
- Return False
- End Try
- End Function
- Private Function IsExecutedInIDE() As Boolean
- Return Debugger.IsAttached
- End Function
leider zeigt er mir immer "objektverweis wurde nicht auf eine objektinstanz festgelegt" ... verstehe nur nicht ganz wo der fehler liegt wenn ich die Links anklicke, ist alles richtig.
Danke im vorraus.