Reputation: 93
The following code returns null in some Windows 10 systems
currentDevice = await HidDevice.FromIdAsync(devices.ElementAt(0).Id,
FileAccessMode.ReadWrite);
I found out that this problem could be resolved by reinstalling Windows 10/ or using 'Fresh' option in Windows 10 which removes all the third-party applications. I can't guess which application may has a conflict with the HID device.
Just for your record, I can open a handle to this HID device using WPF Win32 application but in the Universal app I can't!
New Update 7/11/2018
After doing some debugging tasks using WinDbg, we realized that our UWP access is being failed because of some Upperfilters available on this branch: [Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class]. Some of these are made and controlled by Kaspersky anti-virus.
Looking for to see which/why kernel/user driver brings this limitation on getting access to the HID devices for just UWP Store applications?
Upvotes: 0
Views: 1993
Reputation: 8611
From the MSDN document:
The first time this method is invoked by a store app, it should be called from a UI thread in order to display the consent prompt. After the user has granted consent, the method can be invoked from any application thread.
So, You could call this method in Dispatcher.RunAsync
like the following:
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,()=> {
currentDevice = await HidDevice.FromIdAsync(devices.ElementAt(0).Id,
FileAccessMode.ReadWrite);
});
Upvotes: 0