Simple use of WebClient on Windows Phone 7 throws

2019-09-11 05:10发布

问题:

This code works in a WPF app but throws a NetworkException ("server not found") in WP7. Why the difference?

WebClient client = new WebClient();

client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Client_DownloadStringCompleted);
Uri token = new Uri("http://www.bing.com");

client.DownloadStringAsync(token);

Update: It looks like running Fiddler while debugging WP7 was the cause. Fiddler also breaks the browser on the emulator. Will post if I find a workaround for using Fiddler to debug the emulator.

回答1:

Confirmed it works here. Can post code if you want a sample to try.

Might be an idea to check the proxy support doco if you're having trouble communicating out of the network from the emulator.

Proxy Support for Windows Phone Emulator