如何在Windows Phone单元测试中获取设备ID?
我看了这个,但它对我不起作用.
在我的应用程序中,我正在使用这种方法,它适用于那种情况; 但是在单元测试中它不起作用,因为Exception失败:System.UnauthorizedAccessException:拒绝访问.
有什么想法吗?我的相关代码如下:
private static string GetClientID() {
string id = new Guid().ToString();
object objUniqueID;
if(DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out objUniqueID)) {
return ConvertEx.HexStringEncode((byte[])objUniqueID);
}
else {
return "Unknown";
}
}
Run Code Online (Sandbox Code Playgroud)