Driver, COMException errors

1

I am using the following code to scan documents:

Dim manager = New DeviceManager
Dim deviceinfo = manager.DeviceInfos.Cast(Of DeviceInfo)().FirstOrDefault(Function(di) di.Properties("Name").Value = deviceName)
If deviceinfo Is Nothing Then Exit Sub
Dim device As Device = deviceinfo.Connect

Dim dlg = New CommonDialog

Dim Item As Item = device.Items(1)
Item.Properties("Bits Per Pixel").Value = 1
Item.Properties("Horizontal Resolution").Value = 200
Item.Properties("Vertical Resolution").Value = 200

Dim img As ImageFile = dlg.ShowTransfer(Item, FormatID.wiaFormatTIFF, False)

At the last line, I am receiving 2 different error codes. Sometimes I get 0x8021000E, which according to this page, means a WIA_ERROR_EXCEPTION_IN_DRIVER error.

Sometimes I get COMException The remote procedure call failed 0x800706BE

According to this page, driver errors are logged by default to %windir%\wiadebug.log, but I didn't find the any log file there. I did find a file at %windir%\debug\wiatrace.log which seems to contain this information. but it doesn't give me anything more than the actual error.

The program is running on Windows 7 Professional 64-bit. The WIA Service is running.

What steps can I take to resolve this issue?

vb.net
wia
asked on Stack Overflow Nov 4, 2014 by Zev Spitz

1 Answer

0

1) I had a reference to the WIA DLL as if it was not a system COM DLL, but rather an external DLL. Changing this resolved the COM Exception.

2) The WIA driver exception is apparently because I was explicitly setting the resolution values to 200. Without that, the scanning proceeds fine.

On this page, it is recommended to set the DPI to 150, or to 300 or more, and that some scanners have a problem with DPI of less than 300. (I will update this answer once I have checked this.)

answered on Stack Overflow Nov 13, 2014 by Zev Spitz

User contributions licensed under CC BY-SA 3.0