4

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?

Alexander Galkin
  • 12,086
  • 12
  • 63
  • 115

4 Answers4

3

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.

Derek Beattie
  • 9,429
  • 4
  • 30
  • 44
  • 1
    With NetLimiter 3, you can't set a download limit of 0. To cut off the internet to the device, click the circle in the "Outgoing Blocker" column and select "Deny". This has been perfect for testing no connection in my app. – Sandy Aug 16 '12 at 15:17
  • Sounds good, although version 3.0.0.11 won't install on Windows 8 64bit or Windows Server 2012 64 bit :( – Greg Woods Jul 11 '13 at 08:54
  • 2012 now has the Simulation Dashboard for testing different connection scenarios. – Derek Beattie Jul 16 '13 at 02:37
2

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.

Community
  • 1
  • 1
Bryan Watts
  • 1,415
  • 12
  • 23
2

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;    
}
Community
  • 1
  • 1
Edward
  • 7,346
  • 8
  • 62
  • 123
  • 1
    Thank you for your code. I don't have problems with detecting whether there is connection or no. I just want to test some components -- like Bing maps and Web Browser -- how they behave if there is no connection. I just basically only need to disconnect the emulator from network. – Alexander Galkin Feb 11 '12 at 20:55
0

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...