c# - Microsoft.Phone.ni.dll 中的 UnauthorizedAccessException

标签 c# windows-phone-8 visual-studio-2013

我正在尝试获取 Windows Phone 8 中的 device_id。我试过这样做:

byte[] myDeviceID = (byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId");
string DeviceIDAsString = Convert.ToBase64String(myDeviceID);

还有这个:

DeviceExtendedProperties.GetValue("DeviceUniqueId").ToString();

两者都导致以下异常:

An exception of type 'System.UnauthorizedAccessException' occurred in Microsoft.Phone.ni.dll but was not handled in user code

Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

我该如何解决这个问题?

最佳答案

您需要在应用程序 list 文件中添加所需的功能。特别是,尝试添加此功能:

ID_CAP_IDENTITY_DEVICE

供引用:

关于c# - Microsoft.Phone.ni.dll 中的 UnauthorizedAccessException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24446206/

相关文章:

c# - 强制 VB.NET 生成与 C# 相同的字符串比较表达式?

c# - 如何在 .NET 中为 Web api 编写单元测试

map - 在 Windows Phone 8 上更改 map 控件上的语言

c# - 将远程服务器路径与文件路径组合时 Path.Combine 不起作用

c++ - 迁移到VS2013比较运算符错误C2678 :binary '==' no operator

c# - Umbraco 与 Sitefinity

c# - 如何生成没有头部的xml文件

xaml - 电话 8 XAML : Horizontal Alignment in LongListSelector

azure - 在 Windows Phone 8 和 Windows 8 Store 应用程序之间共享数据

C++ - 为离线 VS2013 加载 Microsoft 符号