【发布时间】:2013-10-01 10:13:27
【问题描述】:
我正在尝试使用以下代码为 Android 应用提取一个简单的 RSS 提要:
public async Task<IList<Episode>> PullEpisodesAsync(int page)
{
string xmlFeed = "";
try
{
using (WebClient wc = new WebClient())
{
var uri = new Uri(Const.FeedEndpoint); // http://spotlightenglish.com/feeds/appfeed/
xmlFeed = await wc.UploadStringTaskAsync(uri, "GET", "");
}
}
catch (System.Net.WebException wex)
{
Console.WriteLine("WebExceptionStatus: {0}", wex.StackTrace);
}
IList<Episode> episodes = ParseFeed(xmlFeed);
return episodes;
}
我得到了一个运行时异常,它没有给我太多继续:
WebExceptionStatus:在
System.Net.WebClient+c_async15.MoveNext ()
[0x00000] in :0 --- 堆栈跟踪结束 以前抛出异常的位置 --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[0x00000] 在 :0 在
System.Runtime.CompilerServices.TaskAwaiter`1[System.String].GetResult () [0x00000] in :0 at
Spotlight.EpisodePoller+c_async1.MoveNext ()
[0x000e2] 在
/Users/Jannie/Workshop/SpotlightEnglish/Elements/EpisodePoller.cs:52
[聚焦] Web 异常:执行 WebClient 时发生错误
请求。
我不在代理或防火墙后面,可以通过测试设备浏览提要 url,并在我的应用清单中指定了 Internet 访问权限。
任何关于如何开始调试的指针将不胜感激。
【问题讨论】:
-
什么是
ex.Message?你试过WebClient.DownloadStringTaskAsync()吗? -
ex.Message:
An error occurred performing a WebClient request. -
耶!!
DownloadStringTaskAsync()完美运行。
标签: c# debugging xamarin.android webclient