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.
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_BUSYerror.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With