Categories
7.0 7.5 C#.NET Microsoft VB.NET Windows Phone

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:

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

Did my solution solve your problem? Leave a reply.

Categories
7.0 7.5 C#.NET Microsoft SDK 7.1 VB.NET Visual Studio Windows Phone

Silverlight for Windows Phone Project Template missing

Windows Phone SDK 7.1 automatically installs Microsoft Visual Studio 2010 Express edition.
If you have installed another edition of Microsoft Visual Studio 2010 you can also use this to create Windows Phone Projects.
Microsoft Visual Studio 2010 Express edition and the other editions are stored in the same Program Files folder “Microsoft Visual Studio 10.0”.

Cause:

Silverlight for Windows Phone Project Template is installed but in another language so when you try to create a new Project with the other Microsoft Visual Studio 2010 edition (NOT EXPRESS) the Silverlight for Windows Phone value into the Installed Templates list is missing.

Solution 1:

Uninstall Windows Phone SDK and reinstall it in the same language of the other Microsoft Visual Studio 2010 edition.

Solution 2 (UNDER THE HOOD):

Follow these Steps:

  1. Understand Microsoft Locale ID Values, it’s a table with correspondence between Language and Local ID.
  2. Store the Local ID value of your other Microsoft Visual Studio 2010 (NOT EXPRESS) editions languages.
  3. Go under <Visual Studio Install Path>\\Common7\\IDE\\ProjectTemplates\\<Language>\\Silverlight for Windows Phone\\
    for example:

    C:\\Program Files\\Microsoft Visual Studio 10.0\\Common7\\IDE\\ProjectTemplates\\CSharp\\Silverlight for Windows Phone
    
  4. Copy and paste the folder inside “Silverlight for Windows Phone” (for example: “1033”) and rename it with the other Local ID (stored at the Step 2).
  5. Repeat Steps 3-4 for each language you’ll use.
  6. Close all Microsoft Visual Studio 2010 running instances.
  7. Run a Command Prompt Window “as Administrator” and enter the following command (devenv is located in <Visual Studio Install Path>\\Common7\\IDE\\):
    devenv /InstallVSTemplates

    this operation, that registers the installed templates, may take several minutes.

Now you can create your Windows Phone Project with all your Microsoft Visual Studio 2010 editions.

NOTE:
If my solutions not work you can try to run the following command:

devenv /ResetSkipPkgs

that clears all SkipLoading tags added to VSPackages.

References:
Devenv Command Line Switches

Did my solution solve your problem? Leave a reply.