我正试图通过.net控制台应用程序获取硬件id(目标framewotk是
net8.0-windows10.0.17763.0
).
代码相当琐碎,只是
var token = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);
无论我得到什么
Unhandled exception. System.Runtime.InteropServices.COMException (0x80010117)
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
at WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
at ABI.Windows.System.Profile.IHardwareIdentificationStaticsMethods.GetPackageSpecificToken(IObjectReference _obj, IBuffer nonce)
at Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(IBuffer nonce)
at TPMGames.Program.Main(String[] args) in C:\Projects\TPMGames\TPMGames\Program.cs:line 7
COMException代码表示
Call context cannot be accessed after call completed.
.
[STAThread]
但没有变化。
文档中的某个地方说这是针对商店应用程序的。有什么方法可以在仅限windows的控制台应用程序中使用它吗?