Windows phone 7 WP7 HttpWebRequest调用方法出错

Windows phone 7 WP7 HttpWebRequest调用方法出错,windows-phone-7,c#-4.0,silverlight-4.0,httpwebrequest,Windows Phone 7,C# 4.0,Silverlight 4.0,Httpwebrequest,我调用我的方法,比如HttpWebRequest,它会给我这样的错误 我的代码是这样的 HttpWebRequest objHttpWebRequest = System.Net.WebRequest.CreateHttp("http://url"); objHttpWebRequest.BeginGetResponse(r => { WebResponse response = null; try

我调用我的方法,比如HttpWebRequest,它会给我这样的错误 我的代码是这样的

HttpWebRequest objHttpWebRequest = System.Net.WebRequest.CreateHttp("http://url");
        objHttpWebRequest.BeginGetResponse(r =>
        {
            WebResponse response = null;
            try
            {
                response = objHttpWebRequest.EndGetResponse(r); //End Async Call to the URL
                using (var stream = response.GetResponseStream())
                using (var reader = new StreamReader(stream)) //get data in StreamReader
                {
                    string contents = reader.ReadToEnd(); //read content from reader and store it in content
                    XElement xmlResult = XElement.Parse(contents);
                    AEGAPI.clsGlobal.RandomToken = xmlResult.Value;
                }

我的错误报告是

System.NotSupportedException occurred
  Message=Timeouts are not supported on this stream.
  StackTrace:
       at System.IO.Stream.get_WriteTimeout()
       at MS.Internal.InternalNetworkStream.get_Length()
       at System.IO.StreamReader.ReadToEnd()
       at AEGAPI.clsAEGAPI.<>c__DisplayClass3.<Authenticate>b__0(IAsyncResult r)
       at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.<InvokeGetResponseCallback>b__8(Object state2)
       at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadPool.WorkItem.doWork(Object o)
       at System.Threading.Timer.ring()
发生System.NotSupportedException异常
Message=此流不支持超时。 堆栈跟踪: 在System.IO.Stream.get_WriteTimeout()处 在MS.Internal.InternalNetworkStream.get_Length()处 在System.IO.StreamReader.ReadToEnd()中 在AEGAPI.clsAEGAPI.c_uuu显示class3.b_uuu0(IAsyncResult r) 在System.Net.Browser.ClientHttpWebRequest.c__中显示ClassA.b__8(对象状态2) 位于System.Threading.ThreadPool.WorkItem.WaitCallback\u上下文(对象状态) 在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态) 在System.Threading.ThreadPool.WorkItem.doWork(对象o)处 在System.Threading.Timer.ring()中
谢谢你的帮助

使用WebClient.DownloadStringAsync()不是更简单吗


你有什么样的错误?这个流不支持超时。哦,我明白了。我第一次看这张照片时遇到了麻烦。:-谢谢,对于你的回复,你能帮我一点忙吗?我对这个请求有点困惑。我把我检索数据的全部代码都放在这里了。你可以纠正我的代码,那对我将是很大的帮助。我得到这个问题至少3天,所以我可以继续。没有什么比我发布的更多。在你请求更多帮助之前,请至少试一试。
void startDownload(Uri url)
{
    WebClient wc = new WebClient();
    wc.DownloadStringCompleted += MyMethod;
    wc.DownloadStringAsync(url);
}
void MyMethod(object sender, DownloadStringCompletedEventArgs e)
{
    var contents = e.Result;
    XElement xmlResult = XElement.Parse(contents);
    AEGAPI.clsGlobal.RandomToken = xmlResult.Value;
}