WP8 App Close Unexpectedly RRS feed

  • Question

  • I built an windows phone 8 app the gets recipe and recipe details from a web service therefore i must make the application connects to the internet and don't close unexpectedly to be able to publish it at windows phone store

    the problem was

    The application must handle exceptions raised by
    the .NET Framework and not close unexpectedly.
    During the certification process, the application is
    monitored for unexpected closure. An application
    that closes unexpectedly fails certification. The
    application must continue to run and remain
    responsive to user input after the exception is

    Comments: When the device does not have an active data connection, the application terminates at launch.
    Steps to Reproduce:
    1. Disable active data connections on the device.
    2. Launch the application.
    3. Select the "View Recipes" option.
    4. Select any category on the list.
    5. Observe the application unexpectedly terminates.


    to be sure not to terminates unexpectedly i used try catch in every load or calling another screen 


    also used "

    bool isConnected = NetworkInterface.GetIsNetworkAvailable(); if(!isConnected) { 
    // the rest of my code 

    i want to know how to resolve it

    Tuesday, April 30, 2013 5:37 PM

All replies

  • Why don't you test your app in the conditions above? Kill your internet connection and start your application in Debug mode. If there is an exception that will terminate your app, you will catch it right there.

    Toni Petrina
    My blog: Toni codes .NET
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful"

    Tuesday, April 30, 2013 9:20 PM
  • To know the network use this :

    bool isConnected = NetworkInterface.NetworkInterfaceType != NetworkInterfaceType.None;

    This is a time consuming operation. If you can run this on a separate thread. See this thread

    - Girija

    Tuesday, April 30, 2013 10:19 PM
  • i did and it works normally locally and still bug in release mode

    Tuesday, April 30, 2013 11:16 PM
  • If you run it in release mode in your emulator, does it crash?

    Also, did you wrap all network code in a try-catch blocks?

    Toni Petrina
    My blog: Toni codes .NET
    If a post answers your question, please click "Mark As Answer" on that post and "Vote as Helpful"

    Wednesday, May 1, 2013 9:54 PM
  • I just ran the code in release mode in emulator and I did not get any error. Not sure why you are getting it.

    Not a perfect solution but you can silently accept the exception and determine that the connection is not available.

    For example :

    bool isConnected = false;
    isConnected = NetworkInterface.NetworkInterfaceType != NetworkInterfaceType.None;
    catch(Exception de)
    // Accept silently
    // PROCEED .....


    - Girija

    Wednesday, May 1, 2013 11:48 PM