29/08/09 10:30
Master_VB
io ho creato con vari aiuti un aggiornamento per il mio programma con questo codice:
però mi dà questo errore: Riferimento a un oggetto non impostato su un'istanza di oggetto
ma non riesco a capire perchè mi dà questo errore sapete aiutarmi? oppure sapete qualche altro codie per creare un updater?
Imports System.IO Imports System.Net Public Class aggiornamento Dim WithEvents AGG As New WebClient Dim WithEvents downloadagg As WebClient Dim sourceurl = "http://servers.altervista.org/aggiornamenti_programmi/dllocxregister/aggiornamenti.txt" Dim filedir = My.Application.Info.DirectoryPath.ToString Private Sub AGG_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles AGG.DownloadFileCompleted Dim filetext As String = IO.File.ReadAllText(My.Application.Info.DirectoryPath.ToString & "\" & "aggiornamenti.txt") If filetext > My.Application.Info.Version.ToString Then MsgBox("Il tuo programma non e aggiornato, ora inizierà l'aggiornamento", MsgBoxStyle.OkOnly, MsgBoxStyle.Critical) Try downloadagg.DownloadFileAsync(New Uri("http://servers.altervista.org/aggiornamenti_programmi/dllocxregister/dllocxregister.exe"), ("C:\")) Catch ex As Exception MessageBox.Show(ex.Message, "Errore:", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try Label2.Text = "Aggiornamento in corso..." Label1.Text = "Nuova versione trovata!" Else MsgBox("Il programma è aggiornato all'ultima versione disponibile!", MsgBoxStyle.OkOnly, MsgBoxStyle.Information) Label1.Text = "Nessuna nuova versione trovata!" My.Settings.agg = False End If End Sub Private Sub downloadagg_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles downloadagg.DownloadFileCompleted Shell(My.Application.Info.DirectoryPath & "\" & "dllocxregister.exe", AppWinStyle.Hide) End End Sub Private Sub downloadagg_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles downloadagg.DownloadProgressChanged ProgressBar1.Value = e.ProgressPercentage End Sub Private Sub aggiornamento_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ProgressBar1.Minimum = 0 ProgressBar1.Maximum = 100 Try AGG.DownloadFileAsync(New Uri(sourceurl), (filedir)) Catch ex As Exception MessageBox.Show(ex.Message, "Aggiornamento Fallito:", MessageBoxButtons.OK, MessageBoxIcon.Error) My.Settings.agg = False End Try End Sub Private Sub controllo_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles controllo.Tick If My.Settings.agg = False Then Me.Close() Form1.Show() End If End Sub End Class
però mi dà questo errore: Riferimento a un oggetto non impostato su un'istanza di oggetto
ma non riesco a capire perchè mi dà questo errore sapete aiutarmi? oppure sapete qualche altro codie per creare un updater?
aaa