Skip to content

Accessing device sensors in a console app #111468

Answered by huoyaoyuan
ladeak asked this question in Q&A
Discussion options

You must be logged in to vote

Set your target framework to netX.0-windows10.0.x.0, for example net9.0-windows10.0.22621.0, you will get access to the WinRT apis via the integrated Microsoft.Windows.SDK.NET.Ref.Windows package. After NuGet restoring you can directly use the Windows.Device.Sensors namespace.

It's powered by CsWinRT and is the same interface provided by WinUI/MAUI. It's actually a prerequisite to use the UI technologies, so their project setup will bring it in.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ladeak
Comment options

Answer selected by ladeak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants