Page 1 of 1

Capability value can be set only when device is open.

Posted: Thu May 12, 2016 5:06 pm
by sebascomeau
Hi,

We are receiving the error "Capability value can be set only when device is open." randomly when scanning during the day. This error is thrown not when we are manually setting the capabilities but during the image transfer process based on the log file.

Here's our ScanHelper class.
http://cdn.ccnb.ca/vintasoft/20160512/scanhelper.txt

Here's the log file.
http://cdn.ccnb.ca/vintasoft/20160512/v ... 100227.txt

Scanner: HP Scanjet N9120
Vintasoft.WpfTwain.dll version: 10.0.6.1

Thanks for you help,
Sébastien Comeau

Re: Capability value can be set only when device is open.

Posted: Thu May 12, 2016 5:18 pm
by sebascomeau
We also received this error. Check the following stack:

Dijito.FrontEnd.DeviceException: Device is not open: Unknown error 1. ---> Vintasoft.WpfTwain.TwainDeviceException: Device is not open: Unknown error 1. à Vintasoft.WpfTwain.TwainEnvironment.?(DebugLevel A_0, String A_1, ? A_2) à Vintasoft.WpfTwain.TwainEnvironment.?(String A_0, ? A_1) à Vintasoft.WpfTwain.Device.Open() à Dijito.FrontEnd.Helper.ScanHelper.Scan()

Re: Capability value can be set only when device is open.

Posted: Mon May 16, 2016 11:52 am
by Alex
Hi Sébastien,

Thank you for information. Log-file shows that your application tries to set unit of measure when device is transferring image - this is prohibited.

SDK does not have code that sets unit of measure. Your code looks correct, the SetDeviceCapabilities method is correct. BUT "something" sets unit of measure in a wrong state. Please inspect your code and try to find where you are setting the unit of measure.

Best regards, Alexander

Re: Capability value can be set only when device is open.

Posted: Mon May 16, 2016 5:27 pm
by sebascomeau
We found that the problem should be cause by calling the Scan method again before the previous call is finished. However, we are using the synchronous way to acquires the images and the scan method can be call again before the previous call has finished. Explain me more in details each device states. It is safe to check if the device is closed before the scanning process?

Thanks,
Sébastien Comeau

Re: Capability value can be set only when device is open.

Posted: Tue May 17, 2016 2:37 pm
by Alex
You have the problem because you are breaking the modal image acquisition loop when you are throwing an exception if scan is failed or device event occured. Please update your code and call the Device.AcquireModal method until it does not return the AcquireModalState.None value.

Best regards, Alexander