Windows Phone 7: Be Careful with that Product ID!

A couple developers I have been working with have had a problem with their application crashing during certification testing, or their app not working as expected after being published. This problem was difficult to debug since the app worked fine for the developer, but would crash out of the gate during testing. After some investigation, we found that the developer was relying on the Product ID to be a known value.

The Product ID is a GUID used to identify your application in the Windows Phone installed application list. This value stays the same across application updates. The Product ID is not controlled by the developer, but is assigned during the ingestion process. That is, the value created by Visual Studio and stored in WMAppManifest.xml, is not the value that will be used when the application is published.

If you are relying on the Product ID to be a certain value – it won’t be what you expect, when your application is published.

<App xmlns="" 
      ProductID="{eb186f6f-78ab-49d2-937d-daa5d0cb7889}" 
      Title="BestAppEver" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal"
      Author="BestAppEver author" Description="Sample description" Publisher="Cookie1">

Here are a couple of workarounds to consider:

  1. Instead of using the Product ID, use a private scheme to store the unique value your app needs.
  2. If your really need to use the Product ID, you can leverage the way App Hub works. That is, the Product ID is assigned early on in the submission process. Specifically, in Step 1 when you upload your app. You can upload a preliminary version of your app and not submit it for testing. You can then use this Product ID in your code. When your application is ready for submission, you can re-upload your app, overwriting the preliminary version with the final version. The Product ID will not change. See below for sample code on how to read the Product ID at run-time.

To see the Product ID as assigned by Product ID, in your “my apps” list on the dashboard, click on the name of your submission.

clip_image002

Here, you can see the Product ID and the Deep Link. This will not change for this submission.

clip_image004

Code to read the Product ID at run time:

public static string GetProductId() 
{
    System.Xml.Linq.XElement xml = System.Xml.Linq.XElement.Load("WMAppManifest.xml");
    var appElement = (from manifest in xml.Descendants("App") select manifest).SingleOrDefault();
    if (appElement != null) { 
        return appElement.Attribute("ProductID").Value; 
    } 
    return string.Empty; 
}

Mike

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *