Accessing device sensors in a console app #111468
-
I have a .NET console app that is targeting Windows. I would like to access device sensors, for example the light sensor on the device. What is the best way to do this without installing many GBs of SDKs and UI frameworks etc.?
Shouldn't this be a super simple task with great docs? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Set your target framework to 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. |
Beta Was this translation helpful? Give feedback.
Set your target framework to
netX.0-windows10.0.x.0
, for examplenet9.0-windows10.0.22621.0
, you will get access to the WinRT apis via the integratedMicrosoft.Windows.SDK.NET.Ref.Windows
package. After NuGet restoring you can directly use theWindows.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.