Help on AsyncCompletedEventHandler

I'm currently using webClient.DownloadFileAsync to download a file in my coding.

I had place the coding below to auto trigger a method upon download complete

webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);

Question:
I have problem trying to assign a value to the label in Complete method
lb_show.Text = "Download Completed";
I would hit an error upon reaching that line

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

[NullReferenceException: Object reference not set to an instance of an object.]
youtubeWeb._Default.Completed(Object sender, AsyncCompletedEventArgs e) in C:inetpubwwwrootyoutubeWebyoutubeWebMain.aspx.cs:129
System.Net.WebClient.OnDownloadFileCompleted(AsyncCompletedEventArgs e) +22
System.Net.WebClient.DownloadFileOperationCompleted(Object arg) +48
System.Web.AspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state) +73


Appreciate that anyone could suggest any solution
Thanks

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories