我有一个问题:当我在 BackgroundAgent 中创建 HttpWebRequest 时,应用程序会抛出 InvalidCastException。此代码适用于 App 前台任务,但不适用于 BackgroundAgent:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(//InvalidCastException
new Uri(url));
request.BeginGetResponse(r => {
HttpWebRequest httprequest = (HttpWebRequest)r.AsyncState;
try {
完整代码: http: //pastebin.com/zyCHBQuP