[英]Not able to connect to webservice from a WP7 emulator
private void button2_Click(object sender, RoutedEventArgs e)
{
WebClient wb = new WebClient();
wb.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wb_DownloadStringCompleted);
wb.DownloadStringAsync(new Uri("http://weather.yahooapis.com/forecastrss?w=2502265"));
}
void wb_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
XElement xmlResult = XElement.Parse(e.Result);
}
這是我使用的代碼。 我收到錯誤消息“無法連接到遠程服務器”。 我可以從模擬器中的IE瀏覽器連接到Internet。
建議合適的解決方案。
您是否嘗試過重啟模擬器? 因為發生在我身上:我在模擬器上遇到此錯誤,但在簡單的控制台程序中卻沒有遇到此錯誤。 VS重新啟動后,它可以工作。
允許仿真器在面板上。
我無法用您提供的代碼重現您的問題。 您確定您沒有被防火牆遮擋或阻止您的請求嗎? 嘗試使用Fiddler(或類似產品)查看發生了什么。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.