In order for you to get the device unique ID and WL (Windows Live) Anonymous ID you need to first declare a couple of things in your WMAppManifest.xml file. If you attempt to retrieve this information without these capabilities, it will throw a UnauthorizedAccessException. Remember, like all capabilities, the user will be alerted that you require this information before they download your application. So use this only if you need it.
<Capabilities> ... <Capability Name="ID_CAP_IDENTITY_DEVICE"/> <Capability Name="ID_CAP_IDENTITY_USER"/> ... </Capabilities>
Now you can access the the desired properties. First add a using statement
using Microsoft.Phone.info;
Then access the properties.
public static byte[] GetDeviceUniqueID() { byte[] result = null; object uniqueId; if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId)) result = (byte[])uniqueId; return result; } 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; }