Reputation: 3740
When I execute the following code on the dispatcher thread, my windows phone app throws WebException exception each time I start to debug with a fresh emulator:
public MainPage()
{
InitializeComponent();
Dispatcher.BeginInvoke(Moo);
}
private async void Moo()
{
await new WebClient().DownloadStringTaskAsync("http://google.de");
}
Strange enough, it only occurs when there was no emulator instance before and it had to go through the boot process. As long as I press VS' "restart debug" button, I repeatedly get the same error, but if I stop debugging and then start again without closing the emulator, it works just fine.
The Exception itself is pretty much meaningless: The response stream is empty and it terminated with NotFound, while the Status was UnknownError. Stack trace (of the inner web exception):
at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)
Source was System.Windows. Let me know if you need any more info.
How can make it work for the first emulator runs? Where should I look for the error? Certainly not in connectivity of the windows phone I think.
Upvotes: 2
Views: 175
Reputation: 21855
Try with a real device as this could be one of the several limitations the emulator has (for example the emulator is always connected to a 3G network and connected to a power charger).
Upvotes: 1