Application cannot navigate to MainPage

I ran into a strange issue in my WP8.1 RT app - one of my beta testers reported seeing a black screen right after the splash screen. The application does not crash, hang up the phone or other - only black screen instead of MainPage. I have used some Trace methods in the code to track down the issue. The code looks like this:

// OnLaunched method that gets called when the App starts
protected async override void OnLaunched(LaunchActivatedEventArgs e)
{
    await Trace.WriteLineAsync(true, "Launched");
    Frame rootFrame = CreateRootFrame();
    await Trace.WriteLineAsync(true, "Before - better checkup");
    if (rootFrame.Content == null)
    {
        await Trace.WriteLineAsync(false, "Rootframe content was null, navigating");
        if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
            await Trace.WriteLineAsync(false, "Navigation false");
        else await Trace.WriteLineAsync(false, "Navigation was ok");
    }
    await Trace.WriteLineAsync(true, "After - better checkup");
    Window.Current.Activate();
} 

// Method creating the rootFrame:
private Frame CreateRootFrame()
{
    Trace.WriteLineAsync(true, "Create Root frame");
    Frame rootFrame = Window.Current.Content as Frame;
    if (rootFrame == null)
    {
        Trace.WriteLineAsync(true, "Root frame was null");
        rootFrame = new Frame();
        SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
        rootFrame.NavigationFailed += OnNavigationFailed;
        Window.Current.Content = rootFrame;
        Trace.WriteLineAsync(false, "Window content {0}", Window.Current.Content.ToString());
    }
    return rootFrame;
}

      

The beta tester's log looks like this:

2014-10-06 13:02:56: Launched
2014-10-06 13:02:56: Create Root frame
2014-10-06 13:02:56: Root frame was null
Window content Windows.UI.Xaml.Controls.Frame
2014-10-06 13:02:57: Before - better checkup
Rootframe content was null, navigating
Navigation false
2014-10-06 13:02:57: After - better checkup
2014-10-06 13:03:01: App.cs suspending event

      

As you can see , the most important line Navigation false

, which means that

if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
     await Trace.WriteLineAsync(false, "Navigation false");

      

Navigation returns false - I can't navigate inside my frame, no crashes, no hangs - (event pauses), just can't get to MainPage. I disagree on what might be the source of the problem. Moreover, everything works on my phone, other devices are also being debugged and released.

Does anyone have an idea why I can't navigate to my MainPage?

Edit - Added navigation inconsistency:

void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
    Trace.WriteLineAsync(true, "Failed to load page");
    throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}

      

+3


source to share


1 answer


Thanks to Nate Diamond's comment. I started looking for the cause of the problem in a completely different way. I am adding this answer as it might help someone one day.

Finally, after many attempts and help from the beta tester, it turned out that the problem was caused by one of the variables that were initialized before the page constructor. The initialization resulted in an exception that was swallowed by the Navigate method and thus returned false.



It's another matter why the initialization resulted in an exception, but another story.

+5


source







All Articles