"I'm using Leadtools 15 with C#.net 2.0.
In my scanning application I'm using background thread to create, initialize, set some settings and call twainSesstion.AcquireFast(..) to keep GUI "alive".
So everything works fine with Xp Sp2 until Vista. So now I have quite bit a problem with my good old application.
All tests I perfom on Xerox DocuMate 510 (drivers are certified for both Xp and Vista)
1. When opens dialog for source selecting ( session.SelectSource("");)
on Xp I have two choices:
-Xerox DocuMate 510
-Wia-Xerox DocuMate 510
on Vista only one (actually if session initialized not on background thread I have two):
-Wia-Xerox DocuMate 510
2. When call session.AcquireFast("test.tif",
TwainFastUserInterfaceFlags.Show, TwainTransferMode.Buffer,
Leadtools.RasterImageFormat.CcittGroup4, 1, false, 0, true);
on Xp "Scan using .. DocuMate 510.." is shown
on Vista : TwainException: DS or DSM reported error.... is thrown.
Can you help me to clearify this????
Here is sample code:
public partial class Form1 : Form {
private TwainSession session;
private BackgroundWorker worker = new BackgroundWorker();
public Form1() {
Unlock(); RasterCodecs.Startup();
InitializeComponent();
worker.DoWork += worker_DoWork;
}
private void worker_DoWork(object sender, DoWorkEventArgs e) {
CreateSession();
try {
session.AcquireFast("test.tif", TwainFastUserInterfaceFlags.Show, TwainTransferMode.Buffer, Leadtools.RasterImageFormat.CcittGroup4, 1, false, 0, true);
}
catch (Exception ex) {
MessageBox.Show(ex.ToString());
}
CloseSession();
}
private void CreateSession() {
session = new TwainSession();
session.EnableAcquireMultiPageEvent = true;
session.AcquireMultiPage += session_AcquireMultiPage;
session.Startup(new Form(), "", "", "", "", TwainStartupFlags.None);
session.SelectSource("");
}
private void CloseSession() {
session.AcquireMultiPage -= session_AcquireMultiPage;
session.Shutdown();
}
private void session_AcquireMultiPage(object sender, TwainAcquireMultiPageEventArgs e) {
if (InvokeRequired)
BeginInvoke(new Action<TwainAcquireMultiPageEventArgs>(multiPage), new object[] { e });
else
multiPage(e);
}
private void multiPage(TwainAcquireMultiPageEventArgs e) {
label1.Text = string.Format("{0}::{1}::{2}", e.FileName, e.PageNumber, e.FinishScan);
}
private void button1_Click(object sender, EventArgs e) {
worker.RunWorkerAsync();
}
}