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

How to consume Twain in .NET 7 console app? #103

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hello,

I'm trying to consume the Twain library in .NET 7 console app for very simple usage:

1, Open the first scanner founded

  1. Start the scan process
  2. Write some text on the console after the scan process is finished

I tried with the example Saraff.TwainX.NET Core Sample3 (NEW. 28.01.2018) with ScanWorks Scanner and when I run it a try to get scanner this error occurs(https://i.imgur.com/1oEdo3V.png_

Do you have any idea how can this be handled?

Thanks

saraff-9EB1047A4BEB4cef8506B29BA325BD5A commented 1 year ago

Hello, @pavleda For .netstandart 2.0, only TWAIN specification 2.x supported (because twain 1.x use win32 callback message loop for negotiation). So if your scanner don't support twain 2.x that it will not be supported.

You can use net6.0-windows7.0 version of Saraff.Twain.NET or use another DS (driver) for you scanner (or use anoter scanner if it possible).

ghost commented 1 year ago

As I got it right:

If my Twain driver supports 2,x I can go with TwainX library, otherwise, I go with the regular TWAIN library and setup to target .net 6 and windows 7?

saraff-9EB1047A4BEB4cef8506B29BA325BD5A commented 1 year ago

In all case you can use the Saraff.Twain.NET 1.0.32.732 (because it contains versions for .net framework (for windows), .net core (for windows) and .net standard (for any platforms))

ghost commented 1 year ago

Ok, but in Saraff.Twain.NET 1.0.32.732 there is no Twain32 class it's only TwainX. In my POC I can only use TwainX and got the error "Cann't load DSM. Also, i checked and I contain this dll for Twain https://i.imgur.com/6G4EJze.png.

I can share my POC with you if you want

saraff-9EB1047A4BEB4cef8506B29BA325BD5A commented 1 year ago

Saraff.Twain.NET 1.0.32.732 has both Twain32, TwainX classes. If you are using .netstandard then only TwainX class is available, otherwise only Twain32 available.

About dsm, C:\Windows\System32\TWAINDSM.dll - 64 bits for x64 OS or 32 bits for x86_32 OS C:\Windows\SysWOW64\TWAINDSM.dll - 32 bits (for 64 bits OS)

ghost commented 1 year ago

So, for the Targeted framework .NET 7, only TwainX is available, right?

I use 32-bit DSM on 64-bit OS.

saraff-9EB1047A4BEB4cef8506B29BA325BD5A commented 1 year ago

... and Twain32 (net6.0-windows7.0) if you set the windows as target platform.

ghost commented 1 year ago

Alright, but I need to run it also on MacOS