質問

I'm trying to download a JSON from Twitter with all the authorization and stuff.

WebClient wc = new WebClient();
wc.DownloadStringCompleted += (b, a) => {
    if (a.Cancelled)
        MessageBox.Show("Download Canceled!");
    else if (a.Error != null)
        MessageBox.Show("Download Error!");
    else
        string g = a.Result;
};
wc.DownloadStringAsync(new Uri("TWITTER_JSON"));

(TWITTER_JSON is a long address with many authorization headers that gives the JSON)
When I run this the 2nd message ("Download Error!") shows up. Why? And how do I fix this?

役に立ちましたか?

解決

a.Error is actually an Exception object. Have you tried examining it to see what the exception details contain?

MessageBox.Show( a.Error.ToString() );

That will give you more information about what actually went wrong.

You may also find it helpful to read Eric Lippert's recent blog post on how to debug your code.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top