首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web Service >

WP7调用API读取源时出错

2013-03-21 
WP7调用API读取流时出错public void LoadingData(){AndGoPage NavigationContext.QueryString[AndGoPag

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”类型的异常
[解决办法]

 

热点排行