saraff-9EB1047A4BEB4cef8506B29BA325BD5A / Saraff.Twain.NET

Saraff.Twain.NET is the skillful scanning component which allows you to control work of flatbed scanner, web and digital camera and any other TWAIN device from .NET environment. You can use this library in your programs written in any programming languages compatible with .NET technology.
GNU General Public License v3.0
102 stars 35 forks source link

OpenDataSource freeze #61

Closed luisKjuarez closed 4 years ago

luisKjuarez commented 4 years ago

Hi, i created an application to scann over web browser, i have a web service running and listening for http messages, when it call the scanner application (by System.Diagnostics.Process) it freezes at OpenDataSource function but works fine when i run it with double click or debugging on Visual studio. Can You help me?

I realized this because i use log file and never print after OpenDataSource function. here is the code that i use

` try {

                    this._twain32.SourceIndex = 0;
                    writeLogLine("first log");
                   Boolean opened=   this._twain32.OpenDataSource( );
                    if (opened == true)
                    {
                        writeLogLine("log 2" );
                        var _isSupported = (this._twain32.Capabilities.ExtImageInfo.IsSupported() & TwQC.Get) != 0;
                        this._isExtImageInfoAllowed = _isSupported && this._twain32.Capabilities.ExtImageInfo.GetCurrent(); 
                    }
                }
                catch
                {
                    writeLogLine("log fail");
                 }
                writeLogLine("log end"); `
luisKjuarez commented 4 years ago

i found the problem, it was a datasource wich isn't compatible with twain2 it throws an exception, but i don't know why if i run this application with double click, or debugging the exception is catched, but calling the application by system.diagnostics.process it hangs and the exception never catched.

i just added

if (_twain32.GetIsSourceTwain2Compatible(0) == true)

then it works, but i would like to know why it doesn´t work properly with diagnostics.process

best regards

saraff-9EB1047A4BEB4cef8506B29BA325BD5A commented 4 years ago

Hello, @luisKjuarez I think that it can be related with redirect STD IO streams. maybe your the app wait users inputs. Try see the Saraff.Twain.NET CS Samples