L3tum / HardwareInformation

.NET Standard Cross-Platform Hardware Information Gatherer
MIT License
56 stars 11 forks source link

"Invalid query" Exception thrown in WindowsInformationProvider in Windows 8.1 #17

Closed Jinjinov closed 3 years ago

Jinjinov commented 4 years ago

Your HardwareInformation library look really promising, judging by the code, but I can't get the NuGet to gather any information at all (it just fails silently) so I downloaded the source code.

The class WindowsInformationProvider throws an "Invalid query" exception.

I am using Visual Studio 2019 version 16.5.2 on Windows 8.1

"NumberOfEnabledCore" causes an exception on "mos.Get()" in line 21.

"ConfiguredClockSpeed" causes an exception on "mos.Get()" in line 104.

If I delete both, it works fine.

I suspect that WMI queries might be different in Windows 7 / 8 / 8.1 / 10 to some extent.

Would it be possible to implement some safeguards against queries that are not available on certain Windows versions?

Perhaps break down large queries into single queries and wrap them in try/catch?

Or check if the key exists with something similar to ContainsKey() that is available in the Dictionary class?

Or perhaps use "select *"?

L3tum commented 4 years ago

Sorry for the super late reply, I can't get the Github notifications to work right^^

The two values you mention do not seem to be supported. I'll look into fixing this, thanks for reporting it.

L3tum commented 4 years ago

Should be fixed in d8ed136faccb9c4a43575260eb954926f71a729b, could you test it out?

Jinjinov commented 3 years ago

I am sorry, I don't use your library anymore, because it didn't give me any information, it just failed silently.

I am using https://github.com/Jinjinov/Hardware.Info

Thanks for the reply and the fix though, I appreciate it! :)