Saraff.TwainX Samples
Working examples for Saraff.TwainX 1.0.34 and Saraff.IoC 2.0.0.
Each archive contains:
src/— full solution source, README and build/smoke scripts;bin/— published Release output for the selected sample (net48).
Run the executable from bin/. A TWAIN 2.x DSM and a DS2 data source are
required. The examples were validated with Saraff Screen DS.
Platform note: the package is
netstandard2.0, but the runnable in-process examples target .NET Framework 4.8. WithSaraff Screen DSon .NET 10 the native transfer fails afterEndXfer(0xC0000409, BEX64); the same scenario succeeds on .NET Framework 4.8.Saraff.TwainX.Samples.CoreandSaraff.TwainX.Samples.Diare multi-targeted (net48;net10.0).
Minimal
| Platform | Archive | What it shows |
|---|---|---|
| Console | Saraff.TwainX.Minimal.Cli.zip | TwainXAcquisitionSession, saving the transferred stream. |
| WinForms | Saraff.TwainX.Minimal.WinForms.zip | TwainX, EndXfer, IImageFactory<Bitmap>, preview. |
| WPF | Saraff.TwainX.Minimal.Wpf.zip | TwainX, EndXfer, BitmapImage with OnLoad + Freeze(). |
Advanced
| Platform | Archive | What it shows |
|---|---|---|
| Console | Saraff.TwainX.Advanced.Cli.zip | Source selection, capabilities, Native/Memory/File/MemFile, multi-page, progress, timeout, cancellation. |
| WinForms | Saraff.TwainX.Advanced.WinForms.zip | Dedicated STA host, capability UI, transfer modes, page list, save selected/all. |
| WPF | Saraff.TwainX.Advanced.Wpf.zip | Same advanced scenario on WPF. |
MemFile support depends on the data source. Saraff Screen DS keeps
XferMech=Native; the samples read the actual XferMech.GetCurrent() and save
the stream with the actual format.
Dependency injection
Uses Saraff.IoC 2.0.0:
[ServiceRequired],Singleton/Scoped/Transient,CreateScope();- named
IStreamProviderregistrations; ResolveAll<IListener>();[ProxyRequired]+IListenerinterception;IAsyncInitializable/IAsyncDisposable;TwainX.Site = new ServiceSite(twain, container)so that native transfer resolvesIImageHandlerandIStreamProviderfrom the container.
| Platform | Archive | What it shows |
|---|---|---|
| Console | Saraff.TwainX.Di.Cli.zip | DI, scopes, listener, handler/provider log, --smoke. |
| WinForms | Saraff.TwainX.Di.WinForms.zip | DI + WinForms, IImageFactory<Bitmap>. |
| WPF | Saraff.TwainX.Di.Wpf.zip | DI + WPF, IImageFactory<BitmapImage>. |
Quick commands
# Minimal CLI
.\bin\Saraff.TwainX.Minimal.Cli.exe --output .\out\scan.bmp
# Advanced CLI
.\bin\Saraff.TwainX.Advanced.Cli.exe --list
.\bin\Saraff.TwainX.Advanced.Cli.exe --source 0 --xfer Native --dpi 200 --out-dir .\out
# DI smoke
.\bin\Saraff.TwainX.Di.Cli.exe --smoke --out-dir .\out\di
See src/README.md inside each archive for all options and limitations.
Legacy archives
The 2018 archives target older package names and API shapes: