2MuchRiceMakesMeSick
February 18th, 2008, 09:33 AM
The following code produces a Unhandled exception error that is basically like a general error.
Nothing shows in the message box for the error..the program just crashes
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
String^ sLocalFileName = "c:\\Users\\User\\Desktop\\dog.jpg";
String^ sUrlPath = "http://imgsrv.kcbs.com/image/kcbs/UserFiles/Image/uno_clo.jpg";
WebClient ^ wc = gcnew WebClient ();
Uri ^ myUri = gcnew Uri (sUrlPath);
wc->DownloadFileCompleted += gcnew AsyncCompletedEventHandler (this,&Form1::myDownloadComplete);
wc->DownloadFileAsync(myUri, sLocalFileName);
}
private: void myDownloadComplete(Object ^ sender, AsyncCompletedEventArgs ^ e)
{
MessageBox::Show(e->Error->Message->ToString());
}
This is the error I get
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an invocation.
Nothing shows in the message box for the error..the program just crashes
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
String^ sLocalFileName = "c:\\Users\\User\\Desktop\\dog.jpg";
String^ sUrlPath = "http://imgsrv.kcbs.com/image/kcbs/UserFiles/Image/uno_clo.jpg";
WebClient ^ wc = gcnew WebClient ();
Uri ^ myUri = gcnew Uri (sUrlPath);
wc->DownloadFileCompleted += gcnew AsyncCompletedEventHandler (this,&Form1::myDownloadComplete);
wc->DownloadFileAsync(myUri, sLocalFileName);
}
private: void myDownloadComplete(Object ^ sender, AsyncCompletedEventArgs ^ e)
{
MessageBox::Show(e->Error->Message->ToString());
}
This is the error I get
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an invocation.