Question

I am using WIA to connect to a scanner. I enumerate the device Infos and then try connecting to the device. I keep getting the exception.

Exception from HRESULT: 0x80210006

I am calling the code in the code behind of a WPF window.

        DeviceManager manager = new DeviceManagerClass();
        DeviceInfo device = null;
        foreach (DeviceInfo deviceInfo  in manager.DeviceInfos)
        {
            var ID = deviceInfo.DeviceID;
            var props = deviceInfo.Properties ;
            foreach (Property property in props)
            {
                var name = property.Name;
                var descr = property.get_Value() as string;
            }
            var type = deviceInfo.Type;
            if (type == WiaDeviceType.ScannerDeviceType)
                device = deviceInfo;
        }
        if (device != null)
              device.Connect();

I can't figure out why this is happening. Any help would be appreciated.

Was it helpful?

Solution

HRESULT: 0x80210006 is WIA_ERROR_BUSY.

From the WIA API Error Codes page:

WIA_ERROR_BUSY        The WIA device is busy.

According to Communicating with a WIA Device in Multiple Threads or Applications, it looks like something else may be accessing the device:

If a thread currently has a device locked (it is actively communicating with that device) and another thread attempts to call a method that actively communicates with the device, the method returns a WIA_ERROR_BUSY error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top