Search code examples
uwpscanning

Why UWP cannot find ImageScanner class?


I try to use a flatbed scanner from UWP. Checked the documentation and it looked simple and straightforward.

However I certainly miss something because I cannot build (ImageScanner is underscored in the editor):

The type or namespace name 'ImageScanner' cannot be found

Obviously, I have the using Windows.Devices.Scanners; in the file. And even that one is weird, because IntelliSense cannot find that namespace but the using line raises no error. I tried with a rubbish namespace and, as expected, with that the using fails.

My project is a new Windows Universal Blank App. Haven't changed anything just started to write my class.

Visual Studio 2017 v4.7.03056
Target Platform Version: 10.0.17134.0

Should I change some project properties or app manifest? The only thing I've read that this scanner API works only on desktop UWP and not on mobile. I tried to change the TargetDeviceFamily in the appxmanifest from Windows.Universal to Windows.Desktop but did not help.


Solution

  • If you dig into the documentation of any class within this namespace, you will find out that it is in fact defined in the Windows Desktop Extension SDK:

    Extension SDK

    This means you have to reference this extension first. Right-click your UWP project in the Solution Explorer, select Add, Reference. In the opened dialog window select Universal Windows, Extensions on the left-hand side and then find and check appropriate version of the Windows Desktop Extensions for the UWP. After you confirm the dialog, you should be able to see the members listed in IntelliSense.

    Windows Desktop Extension SDK