Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SaneWinDS compatibility #327

Closed
ostasevych opened this issue Mar 10, 2024 · 7 comments
Closed

SaneWinDS compatibility #327

ostasevych opened this issue Mar 10, 2024 · 7 comments
Labels

Comments

@ostasevych
Copy link

ostasevych commented Mar 10, 2024

I am trying to find out a reliable twain client for windows, sanetwain doesn't want to work with native scanning, and needs to call scanimage every time, wia clears the settings after each restart of the client, and needs to change the id of device every time the client is restarted.

Finally I was trying to conquer SaneWinDS which has the most recent developments, and here I also failed. Modes native or memory constantly reports the error:

System.Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

Server stack trace: 
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at DS_EntryWrapper.Message_To_DS(DS_EntryWrapper* , TW_IDENTITY* _pOrigin, UInt32 _DG, UInt32 _DAT, UInt16 _MSG, Void* _pData)
   at NTwain.Triplets.Dsm.NativeMethods.DsmWinNew(TWIdentity origin, TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, TWUserInterface data)
   at NTwain.Triplets.Dsm.DsmEntry(TWIdentity origin, TWIdentity destination, Message msg, TWUserInterface data)
   at NTwain.Triplets.UserInterface.EnableDS(TWUserInterface userInterface)
   at NTwain.TwainSession.<>c__DisplayClass128_0.<NTwain.Internals.ITwainSessionInternal.EnableSource>b__0()
   at NTwain.MessageLoopHook.<>c__DisplayClass11_0.<Invoke>b__0(Object o)

Exception rethrown at [0]: 
   at NTwain.MessageLoopHook.Rethrow(Exception ex)
   at NTwain.MessageLoopHook.Invoke(Action action)
   at NTwain.TwainSession.NTwain.Internals.ITwainSessionInternal.EnableSource(SourceEnableMode mode, Boolean modal, IntPtr windowHandle)
   at NTwain.DataSource.Enable(SourceEnableMode mode, Boolean modal, IntPtr windowHandle)
   at NAPS2.Scan.Internal.Twain.TwainSessionScanRunner.Init()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NAPS2.Scan.Internal.Twain.LocalTwainSessionController.<InternalScan>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NAPS2.Scan.Internal.Twain.LocalTwainSessionController.<StartScan>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NAPS2.Remoting.Worker.WorkerServiceImpl.<TwainScan>d__21.MoveNext()
   at void NAPS2.Remoting.RemotingHelper.HandleErrors(Error error)
   at async Task NAPS2.Remoting.Worker.WorkerServiceAdapter.TwainScan(ScanOptions options, CancellationToken cancelToken, ITwainEvents twainEvents)
   at async Task NAPS2.Scan.Internal.Twain.RemoteTwainSessionController.StartScan(ScanOptions options, ITwainEvents twainEvents, CancellationToken cancelToken)
   at async Task NAPS2.Scan.Internal.Twain.TwainScanDriver.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<IMemoryImage> callback)+(?) => { }
   at async Task NAPS2.Scan.Internal.RemoteScanController.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<ProcessedImage, PostProcessingContext> callback)
   at async Task NAPS2.Scan.ScanController+<>c__DisplayClass13_1.<Scan>g__DoScan|6(?)+DoScan(?)
   at async IAsyncEnumerable<ProcessedImage> NAPS2.Scan.ScanController.Scan(ScanOptions options, CancellationToken cancelToken)+(?) => { }

in debug.log:

2024-03-10 19:46:10.2461 24456 Error sending message through pipe System.TimeoutException: The operation has timed out.
   at void System.IO.Pipes.NamedPipeClientStream.Connect(int timeout)
   at bool NAPS2.Remoting.Pipes.SendMessage(Process recipient, string msg)
2024-03-10 19:46:11.6263 24456 Error sending message through pipe System.TimeoutException: The operation has timed out.
   at void System.IO.Pipes.NamedPipeClientStream.Connect(int timeout)
   at bool NAPS2.Remoting.Pipes.SendMessage(Process recipient, string msg)
2024-03-10 19:47:10.4738 13292 Debug: Using new dsm. 
2024-03-10 19:47:10.5662 13292 Debug: NTwain internal message loop is starting. 
2024-03-10 19:47:10.6441 13292 Debug: Thread 14: OpenManager. 
2024-03-10 19:47:27.8801 12208 Debug: Using new dsm. 
2024-03-10 19:47:27.9671 12208 Using TWAIN DSM: D:\Users\User\Downloads\software\naps2-7.3.1-testtwain\App\lib\_win32\twaindsm.dll 
2024-03-10 19:47:27.9763 12208 NAPS2.TW - Opening session 
2024-03-10 19:47:27.9763 12208 Debug: Thread 1: OpenManager. 
2024-03-10 19:47:29.5252 23988 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. System.Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

Server stack trace: 
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at DS_EntryWrapper.Message_To_DS(DS_EntryWrapper* , TW_IDENTITY* _pOrigin, UInt32 _DG, UInt32 _DAT, UInt16 _MSG, Void* _pData)
   at NTwain.Triplets.Dsm.NativeMethods.DsmWinNew(TWIdentity origin, TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, TWUserInterface data)
   at NTwain.Triplets.Dsm.DsmEntry(TWIdentity origin, TWIdentity destination, Message msg, TWUserInterface data)
   at NTwain.Triplets.UserInterface.EnableDS(TWUserInterface userInterface)
   at NTwain.TwainSession.<>c__DisplayClass128_0.<NTwain.Internals.ITwainSessionInternal.EnableSource>b__0()
   at NTwain.MessageLoopHook.<>c__DisplayClass11_0.<Invoke>b__0(Object o)

Exception rethrown at [0]: 
   at NTwain.MessageLoopHook.Rethrow(Exception ex)
   at NTwain.MessageLoopHook.Invoke(Action action)
   at NTwain.TwainSession.NTwain.Internals.ITwainSessionInternal.EnableSource(SourceEnableMode mode, Boolean modal, IntPtr windowHandle)
   at NTwain.DataSource.Enable(SourceEnableMode mode, Boolean modal, IntPtr windowHandle)
   at NAPS2.Scan.Internal.Twain.TwainSessionScanRunner.Init()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NAPS2.Scan.Internal.Twain.LocalTwainSessionController.<InternalScan>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NAPS2.Scan.Internal.Twain.LocalTwainSessionController.<StartScan>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NAPS2.Remoting.Worker.WorkerServiceImpl.<TwainScan>d__21.MoveNext()
   at void NAPS2.Remoting.RemotingHelper.HandleErrors(Error error)
   at async Task NAPS2.Remoting.Worker.WorkerServiceAdapter.TwainScan(ScanOptions options, CancellationToken cancelToken, ITwainEvents twainEvents)
   at async Task NAPS2.Scan.Internal.Twain.RemoteTwainSessionController.StartScan(ScanOptions options, ITwainEvents twainEvents, CancellationToken cancelToken)
   at async Task NAPS2.Scan.Internal.Twain.TwainScanDriver.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<IMemoryImage> callback)+(?) => { }
   at async Task NAPS2.Scan.Internal.RemoteScanController.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<ProcessedImage, PostProcessingContext> callback)
   at async Task NAPS2.Scan.ScanController+<>c__DisplayClass13_1.<Scan>g__DoScan|6(?)+DoScan(?)
   at async IAsyncEnumerable<ProcessedImage> NAPS2.Scan.ScanController.Scan(ScanOptions options, CancellationToken cancelToken)+(?) => { }

Though, SaneWinDS works fine as a standalone app.
Tested with a test scanner sane service run in wsl2 on the same PC, as the client.

@cyanfish
Copy link
Owner

This is again an issue with the data source, but fortunately SANEWinDS (unlike SaneTwain) is open source, so I was able to make some fixes. Hopefully the author is able to merge them, but in the meantime if you like you can trying taking this SANEWinDS.dll and replacing it in the C:\Windows\twain_32\SANEWinDS folder.

SANEWinDS.zip

@cyanfish cyanfish changed the title SaneWinDS reports System.Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. SaneWinDS compatibility Mar 11, 2024
@ostasevych
Copy link
Author

ostasevych commented Mar 11, 2024

This is again an issue with the data source, but fortunately SANEWinDS (unlike SaneTwain) is open source, so I was able to make some fixes. Hopefully the author is able to merge them, but in the meantime if you like you can trying taking this SANEWinDS.dll and replacing it in the C:\Windows\twain_32\SANEWinDS folder.

SANEWinDS.zip

Thanks! I've tested and see that nothing changed significantly. Should I replace the file in the folder "C:\Program Files(x86)\SaneWinDS" as well?

System.Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

Server stack trace: 
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at DS_EntryWrapper.Message_To_DS(DS_EntryWrapper* , TW_IDENTITY* _pOrigin, UInt32 _DG, UInt32 _DAT, UInt16 _MSG, Void* _pData)
   at NTwain.Triplets.Dsm.NativeMethods.DsmWinNew(TWIdentity origin, TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, TWUserInterface data)
   at NTwain.Triplets.Dsm.DsmEntry(TWIdentity origin, TWIdentity destination, Message msg, TWUserInterface data)
   at NTwain.Triplets.UserInterface.EnableDS(TWUserInterface userInterface)
   at NTwain.TwainSession.<>c__DisplayClass128_0.<NTwain.Internals.ITwainSessionInternal.EnableSource>b__0()
   at NTwain.MessageLoopHook.<>c__DisplayClass11_0.<Invoke>b__0(Object o)

Exception rethrown at [0]: 
   at NTwain.MessageLoopHook.Rethrow(Exception ex)
   at NTwain.MessageLoopHook.Invoke(Action action)
   at NTwain.TwainSession.NTwain.Internals.ITwainSessionInternal.EnableSource(SourceEnableMode mode, Boolean modal, IntPtr windowHandle)
   at NTwain.DataSource.Enable(SourceEnableMode mode, Boolean modal, IntPtr windowHandle)
   at NAPS2.Scan.Internal.Twain.TwainSessionScanRunner.Init()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NAPS2.Scan.Internal.Twain.LocalTwainSessionController.<InternalScan>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NAPS2.Scan.Internal.Twain.LocalTwainSessionController.<StartScan>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NAPS2.Remoting.Worker.WorkerServiceImpl.<TwainScan>d__21.MoveNext()
   at void NAPS2.Remoting.RemotingHelper.HandleErrors(Error error)
   at async Task NAPS2.Remoting.Worker.WorkerServiceAdapter.TwainScan(ScanOptions options, CancellationToken cancelToken, ITwainEvents twainEvents)
   at async Task NAPS2.Scan.Internal.Twain.RemoteTwainSessionController.StartScan(ScanOptions options, ITwainEvents twainEvents, CancellationToken cancelToken)
   at async Task NAPS2.Scan.Internal.Twain.TwainScanDriver.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<IMemoryImage> callback)+(?) => { }
   at async Task NAPS2.Scan.Internal.RemoteScanController.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<ProcessedImage, PostProcessingContext> callback)
   at async Task NAPS2.Scan.ScanController+<>c__DisplayClass13_1.<Scan>g__DoScan|6(?)+DoScan(?)
   at async IAsyncEnumerable<ProcessedImage> NAPS2.Scan.ScanController.Scan(ScanOptions options, CancellationToken cancelToken)+(?) => { }

@cyanfish
Copy link
Owner

Oops sorry I think I uploaded the wrong build, please try this one instead:
SANEWinDS.zip

You might need to right click -> Properties on the DLL and select "Unblock" to get Windows to allow it to run.

You can also update to NAPS2 7.4.0 as it will provide a bit more useful error messages.

@ostasevych
Copy link
Author

ostasevych commented Mar 11, 2024

Oops sorry I think I uploaded the wrong build, please try this one instead: SANEWinDS.zip

You might need to right click -> Properties on the DLL and select "Unblock" to get Windows to allow it to run.

You can also update to NAPS2 7.4.0 as it will provide a bit more useful error messages.

So, what I've done:

  1. upgraded portable version to 7.4.0
  2. replaced SANEWinDS.dll in c:\windows\twaint_32 and c:\windows\sanewinds folders with the attached one v.1.1.0 (in properties)
  3. created profile test with the sanewinds driver

TESTS:

  1. test with default mode:
    Exception UI:
System.ArgumentException: Unsupported pixel type: 48 2 3 16,16,16,0,0,0,0,0
   at void NAPS2.Scan.Internal.Twain.TwainMemoryBufferReader.CopyBufferToImage(TwainMemoryBuffer memoryBuffer, TwainImageData imageData, IMemoryImage outputImage)
   at void NAPS2.Scan.Internal.Twain.TwainImageProcessor.MemoryBufferTransferred(TwainMemoryBuffer memoryBuffer)
   at async Task NAPS2.Remoting.Worker.WorkerServiceAdapter.TwainScan(ScanOptions options, CancellationToken cancelToken, ITwainEvents twainEvents)
   at async Task NAPS2.Scan.Internal.Twain.RemoteTwainSessionController.StartScan(ScanOptions options, ITwainEvents twainEvents, CancellationToken cancelToken)
   at async Task NAPS2.Scan.Internal.Twain.TwainScanDriver.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<IMemoryImage> callback)+(?) => { }
   at async Task NAPS2.Scan.Internal.RemoteScanController.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<ProcessedImage, PostProcessingContext> callback)
   at async Task NAPS2.Scan.ScanController+<>c__DisplayClass13_1.<Scan>g__DoScan|6(?)+DoScan(?)
   at async IAsyncEnumerable<ProcessedImage> NAPS2.Scan.ScanController.Scan(ScanOptions options, CancellationToken cancelToken)+(?) => { }

in debug.log:

2024-03-11 14:41:16.4351 11028 Debug: Using new dsm. 
2024-03-11 14:41:16.6112 11028 Using TWAIN DSM: D:\Users\Ostasevych\Downloads\software\naps2-testtwain\App\lib\_win32\twaindsm.dll 
2024-03-11 14:41:16.6229 11028 NAPS2.TW - Opening session 
2024-03-11 14:41:16.6401 11028 Debug: Thread 1: OpenManager. 
2024-03-11 14:41:18.7163 20676 Unsupported pixel type: 48 2 3 16,16,16,0,0,0,0,0 System.ArgumentException: Unsupported pixel type: 48 2 3 16,16,16,0,0,0,0,0
   at void NAPS2.Scan.Internal.Twain.TwainMemoryBufferReader.CopyBufferToImage(TwainMemoryBuffer memoryBuffer, TwainImageData imageData, IMemoryImage outputImage)
   at void NAPS2.Scan.Internal.Twain.TwainImageProcessor.MemoryBufferTransferred(TwainMemoryBuffer memoryBuffer)
   at async Task NAPS2.Remoting.Worker.WorkerServiceAdapter.TwainScan(ScanOptions options, CancellationToken cancelToken, ITwainEvents twainEvents)
   at async Task NAPS2.Scan.Internal.Twain.RemoteTwainSessionController.StartScan(ScanOptions options, ITwainEvents twainEvents, CancellationToken cancelToken)
   at async Task NAPS2.Scan.Internal.Twain.TwainScanDriver.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<IMemoryImage> callback)+(?) => { }
   at async Task NAPS2.Scan.Internal.RemoteScanController.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<ProcessedImage, PostProcessingContext> callback)
   at async Task NAPS2.Scan.ScanController+<>c__DisplayClass13_1.<Scan>g__DoScan|6(?)+DoScan(?)
   at async IAsyncEnumerable<ProcessedImage> NAPS2.Scan.ScanController.Scan(ScanOptions options, CancellationToken cancelToken)+(?) => { }
2024-03-11 14:41:25.0825 20676 Killing unresponsive worker 
  1. test with the memory mode:
    Exception in UI:
System.ArgumentException: Unsupported pixel type: 48 2 3 16,16,16,0,0,0,0,0
   at void NAPS2.Scan.Internal.Twain.TwainMemoryBufferReader.CopyBufferToImage(TwainMemoryBuffer memoryBuffer, TwainImageData imageData, IMemoryImage outputImage)
   at void NAPS2.Scan.Internal.Twain.TwainImageProcessor.MemoryBufferTransferred(TwainMemoryBuffer memoryBuffer)
   at async Task NAPS2.Remoting.Worker.WorkerServiceAdapter.TwainScan(ScanOptions options, CancellationToken cancelToken, ITwainEvents twainEvents)
   at async Task NAPS2.Scan.Internal.Twain.RemoteTwainSessionController.StartScan(ScanOptions options, ITwainEvents twainEvents, CancellationToken cancelToken)
   at async Task NAPS2.Scan.Internal.Twain.TwainScanDriver.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<IMemoryImage> callback)+(?) => { }
   at async Task NAPS2.Scan.Internal.RemoteScanController.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<ProcessedImage, PostProcessingContext> callback)
   at async Task NAPS2.Scan.ScanController+<>c__DisplayClass13_1.<Scan>g__DoScan|6(?)+DoScan(?)
   at async IAsyncEnumerable<ProcessedImage> NAPS2.Scan.ScanController.Scan(ScanOptions options, CancellationToken cancelToken)+(?) => { }

in debug.log:

2024-03-11 14:42:18.7181 20676 Killing unresponsive worker 
2024-03-11 14:42:24.5590 10896 Debug: Using new dsm. 
2024-03-11 14:42:24.6447 10896 Using TWAIN DSM: D:\Users\Ostasevych\Downloads\software\naps2-testtwain\App\lib\_win32\twaindsm.dll 
2024-03-11 14:42:24.6568 10896 NAPS2.TW - Opening session 
2024-03-11 14:42:24.6707 10896 Debug: Thread 1: OpenManager. 
2024-03-11 14:42:26.3021 20676 Unsupported pixel type: 48 2 3 16,16,16,0,0,0,0,0 System.ArgumentException: Unsupported pixel type: 48 2 3 16,16,16,0,0,0,0,0
   at void NAPS2.Scan.Internal.Twain.TwainMemoryBufferReader.CopyBufferToImage(TwainMemoryBuffer memoryBuffer, TwainImageData imageData, IMemoryImage outputImage)
   at void NAPS2.Scan.Internal.Twain.TwainImageProcessor.MemoryBufferTransferred(TwainMemoryBuffer memoryBuffer)
   at async Task NAPS2.Remoting.Worker.WorkerServiceAdapter.TwainScan(ScanOptions options, CancellationToken cancelToken, ITwainEvents twainEvents)
   at async Task NAPS2.Scan.Internal.Twain.RemoteTwainSessionController.StartScan(ScanOptions options, ITwainEvents twainEvents, CancellationToken cancelToken)
   at async Task NAPS2.Scan.Internal.Twain.TwainScanDriver.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<IMemoryImage> callback)+(?) => { }
   at async Task NAPS2.Scan.Internal.RemoteScanController.Scan(ScanOptions options, CancellationToken cancelToken, IScanEvents scanEvents, Action<ProcessedImage, PostProcessingContext> callback)
   at async Task NAPS2.Scan.ScanController+<>c__DisplayClass13_1.<Scan>g__DoScan|6(?)+DoScan(?)
   at async IAsyncEnumerable<ProcessedImage> NAPS2.Scan.ScanController.Scan(ScanOptions options, CancellationToken cancelToken)+(?) => { }
2024-03-11 14:43:26.3154 20676 Killing unresponsive worker 

  1. Test with the old DSM mode:
    no exception in UI it worked with numerous scanned pages till I broke the progress;
    in debug.log:
2024-03-11 14:44:16.8522 24784 Debug: Using old dsm in windows. not C:\WINDOWS\system32\twaindsm.dll 
2024-03-11 14:44:16.9865 24784 Using TWAIN DSM: C:\WINDOWS\twain_32.dll 
2024-03-11 14:44:16.9949 24784 NAPS2.TW - Opening session 
2024-03-11 14:44:16.9949 24784 Debug: Thread 1: OpenManager. 
2024-03-11 14:44:17.0386 24784 NAPS2.TW - StateChanged (to 3) 
2024-03-11 14:44:17.0386 24784 NAPS2.TW - Finding source 
2024-03-11 14:44:25.3412 20676 NAPS2.TW - Sending cancel event 

image

My SANEWinDS config files:
SANEWinDS.ini:

[Log]
RetainDays=3

[General]
INI_Version=0,8
Version=1.1.8600.41743
SaveDefaultsOnExit=True
OptionValueSetMRU="{"test":"Local Defaults"}"
[SANE]
DefaultHost=3
[Host.3]
NameOrAddress=192.168.232.250
UseTSClientIP=False
Port=6566
Username=
TCP_Timeout_ms=30000
Image_Timeout_s=1200
Device=test:0
AutoLocateDevice=test

test.ini:
test.zip

PS So, it works! Later I will check it on other PCs with real scanners.
Indeed, I've had to unlock DLL file. If I place your modified DLL file to the folder with the SaneWinDS app the app doesn't work itself.

UPD Tested with old DSM on Canon MF3010 + SaneWinDS with your patch. It works!

@cyanfish
Copy link
Owner

Nice. Does the real scanner work with Default as the twain impl? The "Unsupported pixel type" error is because it's trying to scan 48-bit color but NAPS2 only supports 24-bit color. I'm not sure if that's a bug in SANEWinDS or in the test backend you were using to default to 48-bit.

@ostasevych
Copy link
Author

Nice. Does the real scanner work with Default as the twain impl? The "Unsupported pixel type" error is because it's trying to scan 48-bit color but NAPS2 only supports 24-bit color. I'm not sure if that's a bug in SANEWinDS or in the test backend you were using to default to 48-bit.

Yes, it works with the default mode as well. I hope SaneWinDS devs will approve your PR as soon as possible, as it solves one of the major issues.

Meanwhile, is that possible to fix the wia driver as well? ;)

@cyanfish
Copy link
Owner

SANEWinDS version 1.2 has been published with those fixes and more, it seems to be working well now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants