Windows Phone 7 – How to find the device unique id windows live anonymous Id and manufacturer

This post details how to use DeviceExtendedProperties and UserExtendedProperties classes from the Microsoft.Phone.Info namespace to find a WP7 device manufacturer, device unique Id and users Anonymous Windows Live ID as follows:

To be able to obtain the Device Unique ID and Windows Live Anonymous ID you must first add the capabilities to do this to your WMAppManifest.xml file within your WP7 project as follows:

      <Capability Name="ID_CAP_IDENTITY_DEVICE"/>
      <Capability Name="ID_CAP_IDENTITY_USER"/>

One important point to note is that you should only really use the device unique id and anonymous windows live Id in your application if really requires it. The reasoning on msdn is as follows:

DeviceExtendedProperties requires the device identity capability. If your application uses this class, the user will be alerted that the application requires access to the device identity when viewing your application on Windows Phone Marketplace. For this reason, it is recommended that you use this class only if your application requires it.

Note: In the example below the manufacturer is returned from GetManufacturer without needing to list the device identity capability within the WMAppManifest but if you tried to get the device Id onr anonymous Id without the capability it will throw an UnauthorizedAccessException.

The following code example demonstrates how to retrieve the Device Manufacturer, Device Unique ID and Windows Live Anonymous ID

using Microsoft.Phone.Info;
namespace NickHarris.Net
    public static class ExtendedPropertyHelper
        private static readonly int ANIDLength = 32;
        private static readonly int ANIDOffset = 2;
        public static string GetManufacturer()
            string result = string.Empty;
            object manufacturer;
            if (DeviceExtendedProperties.TryGetValue("DeviceManufacturer", out manufacturer))
                result = manufacturer.ToString();

            return result;

        //Note: to get a result requires ID_CAP_IDENTITY_DEVICE
        // to be added to the capabilities of the WMAppManifest
        // this will then warn users in marketplace
        public static byte[] GetDeviceUniqueID()
            byte[] result = null;
            object uniqueId;
            if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))
                result = (byte[])uniqueId;

            return result;

        // NOTE: to get a result requires ID_CAP_IDENTITY_USER
        //  to be added to the capabilities of the WMAppManifest
        // this will then warn users in marketplace
        public static string GetWindowsLiveAnonymousID()
            string result = string.Empty;
            object anid;
            if (UserExtendedProperties.TryGetValue("ANID", out anid))
                if (anid != null && anid.ToString().Length >= (ANIDLength + ANIDOffset))
                    result = anid.ToString().Substring(ANIDOffset, ANIDLength);

            return result;

Other Extended Device information that can be retrieved using this class are:

    DeviceUniqueId – if you are after an id to identify the user you should not use this, use Microsoft.Phone.Info.UserExtendedProperties with a parameter of “ANID”

More details on these extended properties can be found here


Happy 10000 hits time to introduce the team

Hi there, 

Today the team here at made it to the 10,000 hit milestone 

Hit Graph

Hit Graph

We decided to down tools and celebrate with a team photo: 

Team photo

Team photo

Thats an ROI of 10000/10 = 1000 per team member 

And of course the blog would not be complete without mentioning that the photo was taken using a MS lifecam and a custom Silverlight App using the System.Windows.Media namespace specifically CaptureSource, VideoCaptureDevice and CaptureSource.CaptureImageAsync method 

If you’re sad because this blog post is coming to an end and your just not sure what to do with yourself then I can recommend that you go checkout this excellent .NET Blog

Now time to get back to that unpaid job of mine :) 


Search Marketplace on Windows Phone 7 with the MarketplaceSearchTask

This describes the straightforward task of how to search Microsoft Marketplace on Windows Phone 7 using the MarketpalceSearchTask. You should note that you can search by keyword and ContentType. Two usage examples would be as follows:

Example 1: Search Marketplace for “Rock” that is of content type Music – allows interesting application scenarios to be developed particularly for record labels like SONY
Example 2: Search Marketplace for “Your Company Name” that is of content type Application – useful if you want users of your application to be able to find other applications by you/your company.

Implementing Example 1:

  1. Add using statement to the Tasks namespace
  2. using Microsoft.Phone.Tasks;
  3. Create an instance of MarketplaceSearchTask set the ContentType and SearchTerms properties then call Show:
        MarketplaceSearchTask mst = new MarketplaceSearchTask();
        mst.ContentType = MarketplaceContentType.Music;
        mst.SearchTerms = "Rock";
  5. Result: The first screen is the result, with the second screen being the resul of clicking on Rock Classic 100.
  6. MarketplaceSearchTask search for Rock Music

    MarketplaceSearchTask search for Rock Music

Implementing Example 2:
To search for applications all you need to do is change the mst.ContentType = MarketplaceContentType.Applications; and update the Search property

Note: if you have a specific target in marketplace in mind you can use MarketplaceDetailTask.


Asynchronous Image download on Windows Phone 7

When running your solution on local and setting the Source property of the System.Windows.Controls.Image it is not visually apparent that the Image may take some period of time to download simplifying the code the following the original image swap out whereby i was using an arbitrary Uri to an image in Azure Blob Storage that would change at a predefined interval.

imgContent.Source = new BitmapImage(new Uri(arbitraryImageUriThatKeepsChanging));

As soon as the image is available from Azure Blob Storage – or any other hosting provider for that matter if you are not using a CDN and are a long way from your host then or the image is of a large size then it is likely that as soon as the image is set the image content becomes empty until the image is downloaded – i found this to be 10 to 30 seconds over the slow bandwidth of my phone.  To have an empty Image control on the screen was not acceptable so the simple solution is to pull down the image asynchronously using a WebClient then once downloaded update the Image.Source as follows:

Starting the Async download of the image:

WebClient wc = new WebClient();
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
wc.OpenReadAsync(new Uri(arbitraryImageUriThatKeepsChanging), wc);

Handling the completed download and updating the image source – note: have intentionally removed the MVVM implementation here to minimise code in post if using MVVM setup the binding on the Image.Source property to the model Source.

void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
   if (e.Error == null && !e.Cancelled)
         BitmapImage image = new BitmapImage();
         imgContent.Source = image;
      catch (Exception ex)
          //Exception handle appropriately for your app
      //Either cancelled or error handle appropriately for your app

Async download of Images from Azure to windows phone.

Note: WebClient executes on the UI thread if you wish to do this on a background thread and then later update the UI you should use HttpWebRequest and then Dispatcher within your response to update the UI thread.

Note: It would be interesting to configure the Azure CDN to see the improved performance once the node is distributed from a CDN node that is geographically close.


How to Enable IntelliTrace on Windows Azure

If your Azure project targets the .NET framework 4.0 you can utilize IntelliTrace to help debug your application. This post briefly covers how to enable and retrieve your IntelliTrace log.  The issue I was debugging in this scenario was a service I was deploying and ASP .NET MVC website it was initializing /stopping / initializing / stopping repeatedly during the deploy to Azure.

  1. When publishing your service select the Enable IntelliTrace for .NET 4 roles checkbox
  2. Enable IntelliTrace

    Enable IntelliTrace

  3. Let the instance deploy and cycle through the initializing and stopping states
  4. Then to download your IntelliTrace log.  In Server Explorer expand your windows Azure hosted service node, right click on your hosting account and select View IntelliTrace log.  This will be downloaded Async.
  5. View Intellitrace

    View Intellitrace

  6. Once the log is retrieved you can review the exceptions
  7. IntelliTrace


  8.  In this case I had not set the System.Web.MVC assembly to copy local and re-deployed.  Job done.


FREE Event – The Sydney Architecture User Group – Acrhitecting High Performance LOB Applications

: Acrhitecting High Performance LOB Applications
Paul Glavich
Thursday 23/09/2010 06:30 PM
Grace Hotel , Kiralee or Pinaroo Function Room 77 York st Sydney,NSW. 2000

Line of business applications might not be the new twitter or Facebook but often require high degrees of performance. This session will deal with the architectural considerations required to implement such an architecture and provide an open forum where performance issues in todays day to day business applications are discussed.
Paul Glavich is an ASP.NET MVP and a member of the ASPInsiders group with close links to the ASP.NET Team. Paul’s day job is working for Datacom as a solution architect, specialising in the web space but is currently involved in architecting a thick client WPF application. Paul has been working with .Net since its inception, has been in the industry for over 20 years and has written 3 books with the latest one on .NET Performance Testing and Optimization which is available as a free eBook or from Amazon in hardcopy

Monetize your Windows Phone 7 application with Microsft Advertising SDK

This post covers basic test Ads only.

1. Download the SDK – link can be found here
2. Add a reference to the Microsoft.Advertising.Mobile.UI.dll
3. Add a reference in your XAML


4. Use one of the following three variants to display ads

<ad:AdControl AdModel="Contextual" ApplicationId="test_client" AdUnitId="Image300_50" />

<ad:AdControl AdModel="Contextual" ApplicationId="test_client" AdUnitId="Image480_80" />

<ad:AdControl AdModel="Contextual" ApplicationId="test_client" AdUnitId="TextAd" />

5. Job done:

Microsoft Advertising

Microsoft Advertising

Note: currently documentation seems to indicate only available to people with US tax identification number with aps targeted for the US market – more details here:

Those of you interested in a similar service for Australia please email me nicholas dot ian dot harris @ hotmail dot com or reply to this post with your contact details – i will keep the comments private.

Kind Regards,