0
votes

Im about to finish my first Windows Store App and the past two days i have encountered a problem during App testing with Windows App Certification Kit.

The test fails in the "crashes and hangs" test and im getting the following message:

Crashes and hangs
Error Found: The crashes and hangs test detected the following errors:
Application ....................0.0.12_x86__jarrs3vj594qe was detected by Windows Error Reporting and experienced a crash or hang.
Impact if not fixed: An app that stops responding or crashes can cause data loss and is a poor user experience.
How to fix: Investigate, debug the executable(s) in question to identify and fix the problem, then rebuild and re-test the app.

After some testing with Suspension and Shutdown in debug mode i have found that my App crashes if : run i Debugging => Suspend and Shutdown=> run in Debugging again. and the error says that SuspensionManager failed at: weather.Common.SuspensionManager.RestoreAsync();

I think this problem is related to my "Extended Splash screen" without the "Exteded Splash screen" i dont get this error and the App passes the "Crashes and hangs" test. Here is code for App.xaml.cs and Extended splash screen:

sealed partial class App : Application
{
    // Defining gloabal variables used across the App
    public string[] NavigateData { get; set; }
    public NavigationCacheMode NavigationCacheMode { get; set; }
    public parameterItem max1DayAgo = new parameterItem();
    public parameterItem min1DayAgo = new parameterItem();
    public parameterItem max1WeekAgo = new parameterItem();
    public parameterItem min1WeekAgo = new parameterItem();

    public parameterItem max1MonthAgo = new parameterItem();
    public parameterItem min1MonthAgo = new parameterItem();


public List<NameValueItem> tempTrends24Hours = new List<NameValueItem>();
    public List<NameValueItem> tempTrends30Days = new List<NameValueItem>();

    public List<NameValueItem> windSpeedTrends24Hours = new List<NameValueItem>();
    public List<NameValueItem> windSpeedTrends30Days = new List<NameValueItem>();


    public List<NameValueItem> windDirectionTrends24Hours = new List<NameValueItem>();
    public List<NameValueItem> windDirectionTrends30Days = new List<NameValueItem>();

    public List<NameValueItem> windChillTrends24Hours = new List<NameValueItem>();
    public List<NameValueItem> windChillTrends30Days = new List<NameValueItem>();

    public List<NameValueItem> humidityTrends24Hours = new List<NameValueItem>();
    public List<NameValueItem> humidityTrends30Days = new List<NameValueItem>();
    public string appBackgGround;

    public App()
    {
        this.InitializeComponent();
        this.Suspending += OnSuspending;       
    }


    protected async override void OnLaunched(LaunchActivatedEventArgs args)
    {

        //
        if (args.PreviousExecutionState == ApplicationExecutionState.Running)
        {
            Window.Current.Activate();
            return;
        }

        Frame rootFrame = Window.Current.Content as Frame;

        //Getting live tile data
        var uris = new List<Uri> 
                {
                    new Uri("..........WebService.asmx/GetFirstTile"),
                    new Uri("............./GetSecondTile"),
                    new Uri("................./GetStatisticTile"),
                    new Uri(".............../GetNewsTile1"),
                    new Uri("............../GetNewsTile2"),                
                };

        TileUpdater LiveTileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
        LiveTileUpdater.EnableNotificationQueue(true);  // Enable notifications
        LiveTileUpdater.Clear();  // Clear the current set of updates
        LiveTileUpdater.StartPeriodicUpdateBatch(uris, PeriodicUpdateRecurrence.HalfHour);

        //getting bacground image
        try
        {
            ServiceReference.WebServiceSoapClient webServiceObj = new ServiceReference.WebServiceSoapClient();
            appBackgGround = await webServiceObj.GetBackgroundImageAsync();// Get the name of the Background picture
        }
        catch
        {
         appBackgGround = "backgroundImageBlueSky.jpg";

        }



        // Do not repeat app initialization when the Window already has content,
        // just ensure that the window is active
        if (rootFrame == null)
        {
            // Create a Frame to act as the navigation context and navigate to the first page
            rootFrame = new Frame();
            weather.Common.SuspensionManager.RegisterFrame(rootFrame, "appFrame");

            // Her we set the application background Image for all pages  "backgroundImageBlueSky.jpg"
            rootFrame.Background = new ImageBrush
            {
                Stretch = Windows.UI.Xaml.Media.Stretch.UniformToFill,
                ImageSource = new BitmapImage { UriSource = new Uri("ms-appx:///Assets/" + appBackgGround) }

            };

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                    //TODO: Load state from previously suspended application
                    await weather.Common.SuspensionManager.RestoreAsync();

            }
            // Place the frame in the current Window
            Window.Current.Content = rootFrame;
        }

        if (rootFrame.Content == null)
        {
           // Navigating to the extended splash screen
            if (!rootFrame.Navigate(typeof(ExtendedSplashScreen), rootFrame.GetNavigationState()))
            {
                throw new Exception("Failed to create initial page");
            }
        }
        // About page
        var _Helper = new Flyouts.SettingsHelper();

        _Helper.AddCommand<Flyouts.About>("About");
        Window.Current.Activate();
    }      
    private async void OnSuspending(object sender, SuspendingEventArgs e)
    {
        var deferral = e.SuspendingOperation.GetDeferral();
        //TODO: Save application state and stop any background activity
        await weather.Common.SuspensionManager.SaveAsync();
        deferral.Complete();
    }
}

The code for the extended splash screeen: Here i do some webservice calls in order to load data for the first page.

public sealed partial class ExtendedSplashScreen : Page
    {


        public ExtendedSplashScreen()
        {
            this.InitializeComponent();
        }

        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            /*
             * ........
             * ..........
             * ...........
             * ...........
             * ............
             * Here i do some webservice calls to get data for the first page(Mainpage
             * 
             */


            (App.Current as App).NavigateData = startupData;// save the data for the Mainpage to the Global variables

            this.Frame.SetNavigationState(e.Parameter as string);         
            this.Frame.Navigate(typeof(MainPage));// Finally navigate to the Mainpage
        }       
    }
}

Any ideas how i can solve this?

1

1 Answers

0
votes

Did you update you visual studio 2012 to the update 2 ? If not, do so and try again. Anyway, be sure that the boot doesn't take more that 5 seconds or you will fail certification.