Thursday, July 30, 2015

Unexpected Windows Phone errors

I've been updating an app that targets WP8.0.
With a couple of hours spare I've been looking through the dev center health reports to see if there are any exceptions occurring that I can do anything about.
It seems that I'm not be defensive enough in my coding and previously didn't allow for things that should never happen from happening. :S

Yes, really.

Even if it's not displayed an app should always have one tile, the "primary tile" that can be accessed in code so it can be updated.
Like this:

var primaryTile = ShellTile.ActiveTiles.First();

Except when it can't.

According to the stack traces, the above has failed.
The lesson? Always use `FirstOrDefault()` even when there should always be at least one and you want the first.

A page has a State dictionary that can be used for storing details while the app is deactivated/tombstoned.

You should always be able to access it and it should always exist:

protected override void OnNavigatedTo(NavigationEventArgs e)
    if (this.State.Count > 0) 

But then, apparently (according to the exception details) there may be an exception when accessing the `State` property.

For an app with over a million installs the number of times the above have happened is incredibly small but may be worth noting if you want to be super robust in your code. Of course, if you not busy with Windows 10 related things ;)


  1. Some people are incredibly fond of reading books can distinguish the best book being a guide and a book which is not good. It all hangs with your reading through experience.
    2016 Toyota Fortuner Price and Release Date
    2016 Toyota RAV4 Special Edition
    Mclaren 650s Spider Price UK
    Porsche 930 For Sale UK

  2. I had been very impressed by this post, this site happens to be pleasant news Thanks very much for this interesting post, and I meet them more often then I visited this web site.
    2016 Toyota Sequoia
    2016 Toyota Sienna Price and Release Date
    2016 Toyota Yaris Features
    2016 BMW Z4 Review

  3. Retro sunglasses are way cool! For some reason, they about scream “Beach!” at me. It’s
    probably because of
    breitling replica some hidden adolescence
    memory. The alien sunglasses are conceivably
    the a lot of accepted in this category, and for a acceptable reason. Wayfarers are classics. They
    accept a distinctive appearance with clean, simple lines, and they never assume to go out of
    style.Our bounded affair supply store, The Affair Station, aswell has some air-conditioned
    awakening sunglasses. I’ve aswell begin some at louis vuitton
    Claire’s, a alternation abundance for accessories. You ability aswell acquisition some
    “groovy” bargain sunglasses at flea markets, austerity stores, and backyard sales. I’ve had a
    harder time award bargain mens sunglasses
    online. My best antecedent for replica Oakley’s, accept it or not, is a bounded accessibility store.
    I’ve also begin some at ample flea markets that advertise new goods. I assumption there’s just
    not as big a demand for hermes replica mens
    sunglasses.One of the a lot of accepted sunglasses for men, as far as appearance is concerned,
    is aviator sunglasses. Sure, women abrasion them, too, but they attending “tough” on a guy,in
    my claimed opinion. Of rolex replica course, I
    anticipate alien sunglasses attending acceptable on everybody!My admired online antecedent
    for bargain sunglasses has some mens sunglasses, but they accept a larger alternative for
    women. Amazon aswell has some abatement sunglasses for replica watches men, including shades from
    Timberland, Skechers, Christian Dior, Carrera, Ray Ban, Oakley, and more. These aren’t
    knockoffs – they’re the absolute thing. They are, however, abatement sunglasses. I haven’t
    apparent them in food this cheap.