Windows Phone – “Navigation is not allowed when the task is not in the foreground. Error: -2147220990”

When you debug your Windows Phone application that use a task and call the Show method your app crash with the following error message:

System.InvalidOperationException:
Navigation is not allowed when the task is not in the foreground. Error: -2147220990

Solution:

Add Show method in try/catch block

For example:

private void appBarButton_Click(object sender, EventArgs e)
{
  WebBrowserTask task = new WebBrowserTask();
  task.Uri = new Uri("https://www.myerrorsandmysolutions.com/");
  try
  {
    task.Show();
  }
  catch 
  { }
}

Did my solution solve your problem? Leave a reply.

Leave a Reply