Domanda

I am developing a Windows Phone 7 App which is capable to work without internet connection but optionally loads some content from web if network is available.

How can I test this application in Phone Emulator under the condition of having no internet connection?

There is a Settions option available in the main menu, but unlike on real device there is no option to disable data connection. The only solution I came up with is to disable the WiFi adaptor of my development laptop, but this seems to be an ultimate option. Is there any way to force emulator to run in disconnected environment?

È stato utile?

Soluzione

Like you said, I just disconnect my development computer from the internet whenever I want to test a wp7 app under no internet connection. You can't force it from the emulator, but you could probably turn it off using code, but that seems like too much work to me.

Another StackOverflow post.

From WP7 App Hub.

Altri suggerimenti

Another option is to use NetLimiter

Not only can you shut off connection to your app, you can change the speeds to simulate a poor connection and see how your app behaves. NetLimiter and Fiddler are sweet tools.

Check out this question. It has some info on the same problem. Also check out this post.

You can use this method in your code for detecting internet connection. If you put it in a static class as a static method, it works nice.

private bool InternetIsAvailable()
{
    var available = !NetworkInterface.GetIsNetworkAvailable();     
#if DEBUG    
       available = false;    
#endif        
       if (!available)         
       {
           MessageBox.Show("No internet connection is available.  Try again later.");   
           return false;        
       }   
       return true;    
}

There is an easy way...

If your app do not require a online login... Desktop, open the "Internet Explorer" > "Settings" > "Connection" and setup a proxy which is of course not valid. Save the changes. Now, you should not be able to browse a website anymore. After these steps, start the simulator...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top