Windows Phone 8 secondary tiles crash when not in Debug Mode

I am testing a basic secondary live tile(ShellTile) functionality with the code below. Creating the tile works fine but using the tile to navigate to the URI always works in debug mode but not when testing disconnected from the computer and I don't know why. I am testing with just 1 tile. Funny thing is, if I restart, secondary tile will work one more time after the restart. What am I missing?

1> This is the code behind that makes the secondary tile

    string path = @"/Views/test.xaml?text=" + parameter.ToString();
    StandardTileData tileData = new StandardTileData
    {
    Title = parameter.ToString(),
    BackTitle = parameter.ToString(),
    BackContent = parameter.ToString()
    };

ShellTile.Create(new Uri(path, UriKind.Relative), tileData);

2.test.xaml code

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    string text= "";
    text= NavigationContext.QueryString["text"];
}

Thanks, Jamie

Answers


When the Tile which NavigationUri is same with your parameter, the ShellTile.Create method will crash. You should check if the tile is exist first, like this:

ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(parameter));

You can choose Contains or Equals by your content. and then:

if (TileToFind != null)
{
// Tile is existed, you can update it, but not add the same uri tile
}
else
{
// you can add new tile 
}

Need Your Help

Unit Testing Legacy ASP.NET Webforms Applications

.net asp.net unit-testing legacy

I've inherited a legacy web application that has no unit tests in it. I'd like to add some, but am at a loss of where to start. Should I add them to old code? Or just new code going forward? What if

Use Automator to email a word doc

email ms-word applescript automator

I do work over a few computers and use my email address to keep an extra save copy of my files. I'd like to have an Automator service for Microsoft Word that sends an email to myself with the current