C# Microsoft.Phone.ni.dll中的UnauthorizedAccessException

C# Microsoft.Phone.ni.dll中的UnauthorizedAccessException,c#,windows-phone-8,visual-studio-2013,C#,Windows Phone 8,Visual Studio 2013,我正在尝试在Windows Phone 8中获取设备id。我试着这样做: byte[] myDeviceID = (byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId"); string DeviceIDAsString = Convert.ToBase64String(myDeviceID); 这是: DeviceExtendedProperties.GetValue("DeviceUni

我正在尝试在Windows Phone 8中获取设备id。我试着这样做:

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

DeviceExtendedProperties.GetValue("DeviceUniqueId").ToString();
两者都导致了以下异常:

中发生“System.UnauthorizedAccessException”类型的异常 Microsoft.Phone.ni.dll,但未在用户代码中处理

其他信息:访问被拒绝。来自HRESULT的异常:0x80070005 E_访问被拒绝


如何解决此问题?

我想您一定忘了添加功能。ID\u CAP\u IDENTITY\u应该在WMAppMenifest.xml中检查设备,我想您一定忘了添加功能。应在WMAppMenifest.xml中检查ID\u CAP\u IDENTITY\u设备

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

ID_CAP_IDENTITY_DEVICE
供参考:


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

ID_CAP_IDENTITY_DEVICE
供参考: