Client Pay Portal
 windows 8 app

Marine Scout Windows 8 App Root Frame Cert Issue

After many, many, MANY months of testing and certifying, Marine Scout for Windows 8 has finally been released! You can check out the app here:

Get The App!
 

There is a free and paid version. The Paid version allows you to share buoys, set “favorite” buoys, and removes the ads. I’ll be updating the Paid version with more features in the future. This was my 2nd Win 8 app, and my first for a trial / paid scenario. It also uses Bing Maps and the Advertising SDK. The total development time (not counting the recent submission time) took about 2 months to develop.

OK.. so why did it take so long to publish? The app was actually done last fall but took almost 6 months to get through the store. After SEVERAL submissions and failures, I continually received a standard “App failed to function properly” from the cert team with no more details. I reached out to Joe Healy who did an awesome job of connecting me with the DPE team. From there, I had several people help with the app and provide info on possible changes.

DPE ended up taking my source code and submitting it, only to have it fail. He then started some incremental changes and finally got it to pass. I wanted to let everyone in this group know what the issue was so you can avoid it in the future.

The app was created using the Microsoft C# “grid” template. In the template code for the app.xaml.cs file, there is some work done when the app is first launched. This code basically tries to restore the app the way the user left it, or start a new instance of it.
 
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;
 
            // 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();
                //Associate the frame with a SuspensionManager key                                
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
 
                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }
 
                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups"))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate(); 

While this code seems fine, there is an issue that seems to happen sometimes that no one at Microsoft can explain. Sometimes the “rootFrame” object is NULL. This code does handle that case, however, it did ,lead to my issue. For my code I made a central “Exception Handler” function to handle all exceptions. I wrap all of my calls with a try catch and capture the exception. In my Exception Handler I was determining if it was “Debug” mode or not. After that, I redirect the user to an Error page using the following code:
 
            Frame rootFrame = Window.Current.Content as Frame;
    
            if ((bool)App.Current.Resources["debugmode"])
            {
                rootFrame.Navigate(typeof(Error), ex.Message + " - " + ex.StackTrace);
            }
            else
            {
                rootFrame.Navigate(typeof(Error),null);
            } 

The issue here is that when the “rootFrame” is NULL (for some unknown reason) this code bombs out. The app doesn’t “Activate” any frame and it just sits on the Splash Screen. To get around the issue, I added this to my code. This handles the NULL case and properly sets the values.
            Frame rootFrame;
            if (Window.Current.Content != null)
            {
                rootFrame = Window.Current.Content as Frame;
            }
            else
            {
                rootFrame = new Frame();
            }
            if ((bool)App.Current.Resources["debugmode"])
            {
                rootFrame.Navigate(typeof(Error), ex.Message + " - " + ex.StackTrace);
            }
            else
            {
                rootFrame.Navigate(typeof(Error),null);
            }
            Window.Current.Content = rootFrame; 

This development of this app took a long time and ended up needing the help of senior Microsoft devs to complete. I want everyone to know how helpful Joe and the entire DPE team were in making it happen! Hopefully this info helps some of you avoid some pitfalls and gets your apps certified an in the store quickly!
 

Author

Wiz E. Wig, Mascot & Director of Magic
Wiz E. Wig

Director of Magic