So Im trying to download an update file asynchronously and its throwing a null exception:
A first chance exception of type 'System.NullReferenceException' occurred in OnePlus One Toolkit.exe
Additional information: Object reference not set to an instance of an object..
The code is below:
        try { webclient.DownloadFileAsync(new Uri("http://repo-itechy21.tk/toolkit/"), "update.msi"); }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }            
    webclient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(progress);
    webclient.DownloadFileCompleted += new AsyncCompletedEventHandler(Complete);
}
private void Complete(object sender, AsyncCompletedEventArgs e)
{
    if (e.Cancelled == true)
    {
        File.Delete("update.msi");
        MessageBox.Show("Download has been canceled.");
    }
    else
    {
        MessageBox.Show("Download completed! The Program will now exit and update");
        Process.Start("update.msi");
        Application.Exit();
    }
}
It generally throws the exception with either of these two bits of code:
webclient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(progress);
webclient.DownloadFileCompleted += new AsyncCompletedEventHandler(Complete);
I am a noob to c# so explain it in laymans terms if possible please.
