当前位置: 代码迷 >> Web Service >> WP7调用API读取源时出错
  详细解决方案

WP7调用API读取源时出错

热度:354   发布时间:2013-03-21 10:08:17.0
WP7调用API读取流时出错
  public void LoadingData()
        {
            AndGoPage = NavigationContext.QueryString["AndGoPage"];
            if (NavigationContext.QueryString.ContainsKey("cityName"))
            {
                cityName = NavigationContext.QueryString["cityName"];
            }
            client.OpenReadAsync(new Uri("http://php.weather.sina.com.cn/xml.php?city="+ cityName+"&password=DJOYnieT8234jlsK&day=0" , UriKind.RelativeOrAbsolute));
            client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
        }

        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            XElement xmlWeather;
            try
            {
                xmlWeather = XElement.Load(e.Result.ToString());
            }
            catch (Exception)
            {
                MessageBox.Show("获取城市信息失败");
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
                return;


提示e.Result.ReadTimeout”引发了“System.InvalidOperationException”类型的异常

------解决方案--------------------
 
  相关解决方案