在一个UWP应用设备ID(阈值1) [英] Device ID in a UWP app (threshold 1)
问题描述
在电话8.1你可以得到使用的 HardwareIdentification ,即使在文档一>说,它存在的桌面应用程序,它不能用于UWP应用存在。
In Phone 8.1 you could get the device ID using HardwareIdentification, and even though the documentation says it exists for Desktop apps, it does not exist for a UWP app.
什么是替代还是一种方式来获得一个硬件ID对于UWP?
What is the alternative or a way to get a hardware ID for a UWP?
推荐答案
您正在运行到一个共同的问题,从迁移应用程序当Windows(电话)8(0.1)
到的Windows通用平台
。
You're running into a common issue when migrating an app from Windows (Phone) 8(.1)
to the Windows Universal Platform
.
原因你没有看到 HardwareIdentification
很简单:你不引用所需的源
The reason you're not seeing the HardwareIdentification
is pretty simple: You don't reference the required sources!
您只看 AnalyticsInfo
和 AnalyticsVersionInfo
。这是因为他们在通用 器件系列的一部分的,因为文档页面上注明(的 https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.analyticsinfo.aspx 一>)在最底层。
You only see AnalyticsInfo
and AnalyticsVersionInfo
. This is because they are part of the Universal Device Family, as stated on the documentation page (https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.analyticsinfo.aspx) at the very bottom.
HardwareIdentification
然而,这不是在通用的一部分STRONG>的器件系列的,它的桌面
和移动
系列的一部分,阿德里亚诺alread 。在他的评论中指出
The HardwareIdentification
however is not part of the Universal Device Family, it's part of the Desktop
and Mobile
family, as Adriano alread stated in his comment.
To make the info available, you have to add the references to the specific extensions:
之后,确认,检查,如果该类型存在之前调用它:
After that, make sure to check if the type exists, before calling it:
if (Windows.Foundation.Metadata.ApiInformation
.IsTypePresent("Windows.System.Profile.HardwareIdentification"))
这篇关于在一个UWP应用设备ID(阈值1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!