I'm trying to get a hardware id with a .net console app (target framewotk is net8.0-windows10.0.17763.0).
The code is rather trivial, just
var token = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);
However I get
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
The COMException code means Call context cannot be accessed after call completed..
I've tried [STAThread] but no change.
Somewhere in the doc it says that this is for store apps. Is there any way I can make use of it in a windows-only console app?
Or does it need a specific project type?