获取WP8的唯一ID

时间:2014-03-18 07:06:55

标签: c# windows-phone-8

当试图获取imei number null异常时发生。在Windows手机模拟器中运行时。

//请检查

        object uniqueId;
        var hexString = string.Empty;
        if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))
            hexString = BitConverter.ToString((byte[])uniqueId).Replace("-",     string.Empty);
        MessageBox.Show("myDeviceID:" + hexString);

2 个答案:

答案 0 :(得分:3)

我在返回null值时遇到了这个问题。

In WMAppManifest.xml -> Capabilities tab -> switch on ID_CAP_IDENTITY_DEVICE

答案 1 :(得分:0)

在此链接中,他使用GetValue代替TryGetValue并使用其工作: Get Unique Device ID (UDID) under Windows Phone 8