Not able to connect to webservice from a WP7 emulator

£可爱£侵袭症+ 提交于 2019-12-23 05:12:39

问题


 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);

    }

This is code i have used. I am getting an error "Unable to connect to the remote server". I am able to connect to internet from the IE browser in the emulator.

Suggest a suitable solution.


回答1:


Did you try to restart your emulator ? Because it happens to me : I got this error with the emulator but none with a simple console programm. After a restart of VS, it works.




回答2:


I cannot reproduce your problem with the code you have provided. Are you sure you're not stuck behind a firewall or something that blocks your request? Try using Fiddler (or a product like it) to see whats going on.




回答3:


To allow the Emulator in friewall.

  • Open Control Panel\System and Security\Windows Firewall\Allowed Programs
  • Click on "Change Settings" to enable "Allow another program"
  • Browse - > "C:\Program Files (x86)\Microsoft XDE\1.0\XDE.exe"
  • Tick Public / Private Network or both as you are connected to internet.


来源:https://stackoverflow.com/questions/4562887/not-able-to-connect-to-webservice-from-a-wp7-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!