All products / Saraff.TwainX.Extensions
Migration
From 1.0.2.616 to 1.0.3.616
Dependency change
Saraff.TwainX.Extensions 1.0.2.616 referenced Saraff.TwainX.NET 1.0.27.614. Version 1.0.3.616
references Saraff.TwainX 1.0.35.
Both packages ship Saraff.TwainX.dll in the Saraff.TwainX namespace, so they must not be
referenced together. Remove the old reference:
<!-- remove -->
<PackageReference Include="Saraff.TwainX.NET" Version="1.0.27.614" />
<!-- keep -->
<PackageReference Include="Saraff.TwainX.Extensions" Version="1.0.3.616" />
After restore, project.assets.json should contain Saraff.TwainX/1.0.35, not
Saraff.TwainX.NET/1.0.27.614.
New asynchronous API
Version 1.0.3.616 adds:
XDs.AcquireAsync(TwainXAcquireOptions, Action<XCapabilitySession>, CancellationToken);XCapabilitySession.GetCapability<T>,IsCapSupportedandTwainX;- asynchronous source selection, progress and cancellation.
The async path creates a TwainXAcquisitionSession with its own TwainX and dedicated thread. It
uses native transfer and copies each transferred stream into a result-owned MemoryStream. See
Asynchronous acquisition.
Capability conversion
The following behavior is fixed:
XCapabilityValue<T>.IsCurrentandIsDefaultno longer use a direct(T)cast; values are converted with the same rules asSetandValues.Valuessupports typed arrays in addition toobject[].- Enum values can be converted from numbers, strings and other enum types.
nullis converted tonull/default for reference types andNullable<T>; it throwsInvalidCastExceptionfor non-nullable value types.- Unsupported values now throw
InvalidCastExceptionwith the source and target type instead of failing later withNullReferenceException.
Choose T that matches the TWAIN capability type. See Capabilities.
Lifecycle and concurrency
XDsm.Dispose()now unsubscribes from allTwainXevents and closes the owned DSM before disposing the session.- Transfer callbacks are stored in a per-transfer context, not on the manager. A second transfer on
the same
XDsmthrowsInvalidOperationException. - Synchronous and asynchronous acquisition are mutually exclusive per
XDsm. XDs.TwainXno longer callsOpenDataSource()repeatedly when the source is already open. It closes and switches only when the source index differs.XDsm.TwainXandXDs.AcquireAsyncthrowObjectDisposedExceptionafter disposal.XDsm.Create(null)andXDs.Create(null, ...)throwArgumentNullException;XDs.Create(dsm, -1)throwsArgumentOutOfRangeException.
Package metadata
- Version:
1.0.3.616 - License:
LGPL-3.0-or-laterexpression - Repository metadata points to the actual GitHub repository
- Package readme is included in the package
Upgrade
dotnet add package Saraff.TwainX.Extensions --version 1.0.3.616
or:
<PackageReference Include="Saraff.TwainX.Extensions" Version="1.0.3.616" />
From Saraff.Twain.Extensions
Saraff.Twain.Extensions is the extensions package for the Windows Saraff.Twain product
(Twain32, System.Drawing images, TWAIN 1.x and 2.x). Saraff.TwainX.Extensions targets
Saraff.TwainX (TwainX, streams, TWAIN 2.x/DS2).
The two packages are not drop-in replacements:
Saraff.Twain.Extensions |
Saraff.TwainX.Extensions |
|
|---|---|---|
| Core type | Twain32 |
TwainX |
| Image model | System.Drawing.Image |
Stream |
| Target | net462, net8.0-windows |
netstandard2.0 |
| TWAIN | 1.x and 2.x | 2.x / DS2 |
| Source open | XDs.Open() / XDs.Close() |
lazy XDs.TwainX |
| Async | no | XDs.AcquireAsync |
Port the code by replacing the package and adapting the core type, image handling and source
lifecycle. Capability names (TwCap, TwQC, TwSX, TwPixelType) are similar because both
packages wrap TWAIN, but the event argument and image types differ.
Version policy
The package follows the core Saraff.TwainX version for compatibility decisions. The extensions
package version is independent but is validated against the core package at build and publish time.