Click here to Skip to main content
16,005,316 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
This program is a file downloader and after downloading it gives error
VB
Imports System.Net
Imports System.IO
Public Class downloader
    Private WithEvents downloadclint As New WebClient
    Dim Filename, Path As String
    Private Sub Downloaded(sendar As Object, ByVal e As System.Net.DownloadDataCompletedEventArgs) Handles downloadclint.DownloadFileCompleted
        Process.Start(Path & "\" & Filename)
    End Sub
    Private Sub StopBut_Click(sender As Object, e As EventArgs) Handles DownloadBut.Click
        AddHandler time.Tick, AddressOf tik
        AddHandler downloadclint.DownloadProgressChanged, AddressOf Changsize
        AddHandler downloadclint.DownloadFileCompleted, AddressOf Downloaded
        time.Enabled = True : time.Interval = 1
        If DownloadBut.Text = "Stop" Then
            DownloadBut.Text = "Start"
            If MsgBox("Are You Sure ?", MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then downloadclint.CancelAsync()
        ElseIf TextBox1.Text.StartsWith("http://") Or TextBox1.Text.StartsWith("https://") Then
1:
            FBD.ShowDialog()
            If FBD.SelectedPath <> "" Then
                Path = FBD.SelectedPath
            Else
                MsgBox("Select Your Path")
                GoTo 1
            End If
            Dim spliter As String() = Split(TextBox1.Text.Trim, "/", , CompareMethod.Text) : Filename = spliter(UBound(spliter))
            Try
                downloadclint.DownloadFileAsync(New Uri(TextBox1.Text.Trim), Path & "\" & Filename)
            Catch ex As Exception
                MsgBox(ex)
            End Try
            TextBox1.Text = ""
            DownloadBut.Text = "Stop"
        Else
            MsgBox("insert Real Address")
            TextBox1.Text = ""
        End If
    End Sub


and This is error

Exception has been thrown by the target of an invocation.
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart()
mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args)
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(System.Windows.Forms.Control.ThreadMethodEntry tme)
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj)
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallback(System.Windows.Forms.Control.ThreadMethodEntry tme)
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks()
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m)
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m)
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData)
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context)
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context)
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.ApplicationContext context)
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(string[] commandLine)
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args)
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state)
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)
[Native to Managed Transition]
Posted
Updated 30-Jun-15 1:59am
v2
Comments
Suvendu Shekhar Giri 30-Jun-15 8:07am    
Check for the inner exception to see exact exception occured and update the question accordingly.
ZurdoDev 30-Jun-15 8:12am    
If the download works then you can likely ignore it. This happens in ASP.Net so that may be all it is.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900