When trying to retrieve the Unique Device ID using the DeviceExtendedProperties from your Windows Phone application, you might encounter the below error
UnauthorizedAccessException was unhandled by user code
An exception of type ‘System.UnauthorizedAccessException’ occurred in Microsoft.Phone.ni.dll but was not handled in user code.
To resolve this error, verify if the ID_CAP_IDENTITY_DEVICE capability is set in the Application Manifest file. If it is not set, enable it. Save the project, build and run your Windows Phone Project.
You see that UnauthorizedAccessException when trying to get the Device ID would be vanished and you will get the right unique device from the Phone.