Microsoft.Phone.ni.dll中的UnauthorizedAccessException

Seb*_*ier 1 c# windows-phone-8 visual-studio-2013

我正在尝试使用device_idWindows Phone 8.我尝试这样做:

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

还有这个:

DeviceExtendedProperties.GetValue("DeviceUniqueId").ToString();
Run Code Online (Sandbox Code Playgroud)

两者都导致以下异常:

Microsoft.Phone.ni.dll中出现"System.UnauthorizedAccessException"类型的异常,但未在用户代码中处理

其他信息:访问被拒绝.(HRESULT异常:0x80070005(E_ACCESSDENIED))

我该如何解决这个问题?

har*_*r07 6

您需要在App清单文件中添加所需的功能.特别是,尝试添加此功能:

ID_CAP_IDENTITY_DEVICE
Run Code Online (Sandbox Code Playgroud)

以供参考 :