vb.net - Unable to cast object of type, -
this first post hope right place , please nice! thanks.
so issue error while downloading file. have made downloader app download specific file. runs fine until hits download complete event.
here code:
private sub cmddownload_click(byval sender system.object, byval e system.eventargs) handles cmddownload.click try dim webclient new webclient() addhandler webclient.downloadprogresschanged, addressof client_progresschanged addhandler webclient.downloadfilecompleted, addressof client_downloadfilecompleted webclient.downloadfileasync(new uri("https://dl.dropbox.com/s/wtdagv0xvliwvv2/viruslist.dat?dl=0"), application.startuppath + "\viruslist.dat") catch ex exception end try end sub public sub client_progresschanged(byval sender object, byval e system.net.downloadprogresschangedeventargs) try dim bytesin double = double.parse(e.bytesreceived.tostring()) dim totalbytes double = double.parse(e.totalbytestoreceive.tostring()) dim percentage double = bytesin / totalbytes * 100 progbar.value = integer.parse(math.truncate(percentage).tostring()) label3.text = "total complete " + progbar.value.tostring + " %" catch ex exception end try end sub public sub client_downloadfilecompleted(byval sender object, byval e system.net.downloaddatacompletedeventargs) messagebox.show("database has finished downloading!", "download finished...", messageboxbuttons.ok, messageboxicon.exclamation) end sub the error an
unhandled exception: system.invalidcastexception: unable cast object type 'system.componentmodel.asynccompletedeventargs' type 'system.net downloaddatacompletedeventargs', @ database_download.frm.main._lambda$__1(object a0. asynccompletedeventargs a1)
like said runs fine until needs fire downloadcomplete, not messagebox @ pops error. don't understand because have done exact code in other projects without problems. please help!
change signature. msdn documentation
public sub client_downloadfilecompleted(byval sender object, byval e system.componentmodel.asynccompletedeventargs) messagebox.show("database has finished downloading!", "download finished...", messageboxbuttons.ok, messageboxicon.exclamation) end sub
Comments
Post a Comment