I can't tell you exactly when this happens. But it seems that the NavigationService was not instantiated when the app got suspended. Imagine, the app was started in a share pane view and closes itself as soon as it recieved all data.

...same for SessionStateService

This will fix the issue:
```c#
///
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
///
/// The source of the suspend request.
/// Details about the suspend request.
private async void OnSuspending(object sender, SuspendingEventArgs e)
{
IsSuspending = true;
try
{
var deferral = e.SuspendingOperation.GetDeferral();
//Custom calls before suspending.
await OnSuspendingApplicationAsync();
//Bootstrap inform navigation service that app is suspending.
NavigationService?.Suspending();
// Save application state
var saveAsync = SessionStateService?.SaveAsync();
if (saveAsync != null)
{
await saveAsync;
}
deferral.Complete();
}
finally
{
IsSuspending = false;
}
}
```
Thanks for reporting.
As mentioned in #1121, the fix is hiding the real issue (not having an initialized NavigationService). We're redoing part of the application initialization (planned for 1st week of August), so the initial problem will be tackled there.
Hey, no problem. I just needed a solution for my application crash. You are right, the root cause should be resolved, not the effect. 馃槃
Thanks for your work! 馃憤
@bartlannoeye
You told it was planned for 1st week of August. Last days of August - still nothing fixed? :-(
@artemious7 there is a workaround in this thread, so you should not be blocked. Also, we accept PR's from the community, so if you wanted to fix it you can.
The root cause we've experienced is when the UWP app uses App2App Communication Services and the UWP app has previously been suspended or closed. When the next App2App communication comes in, the UWP app is activated via OnBackgroundActivated, thus the Prism InitializeShell and InitializeFrameAsync methods are not executed, so NavigationService and SessionStateService are null.
Actually, we are hoping this is solved with the upcoming Template10/Prism merge.
@brianlagunas Whats the state of the Template10/Prism merge? Is it somewhere tracked?
Brian is currently occupied with family matters. I'll check with Jerry and come back to this when we have an answer.
Any news or even timeline to share?
Jerry was on vacation, he should be back one of these days so I'm trying to get a status update asap.
Got new from Jerry, he's just back out of vacation and is wrapping up some other articles first. The current state of his work can be found in the Template 10 repo. I'm leaving on vacation this weekend and plan to test the upgrade path from v6 to the new code base (and proof test it in a real LoB application) once I'm back and hope to land on something by the end of summer.
Template10 merged complete. This should no longer be an issue.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Thanks for reporting.
As mentioned in #1121, the fix is hiding the real issue (not having an initialized NavigationService). We're redoing part of the application initialization (planned for 1st week of August), so the initial problem will be tackled there.