6
I am using the Twain library for scanner,and the application lists some devices that when selecting does not work,so I debugged and saw that it does not launch the Exception I treated, and yes it freezes in this code
public void Acquire()
{
TwRC rc;
CloseSrc();
if (appid.Id == IntPtr.Zero)
{
Init(hwnd);
if (appid.Id == IntPtr.Zero)
return;
}
try
{
//CONGELA NESSE BLOCO ABAIXO E NÂO LANÇA EXCEPTION
rc = DSMident(appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.OpenDS, srcds);
}
catch(Exception ex)
{
throw new ScannerException("Não foi possivel digitalizar, verifique o driver selecionado!");
}
TwCapability cap = new TwCapability(TwCap.XferCount, 1);
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap);
if (rc != TwRC.Success)
{
CloseSrc();
throw new ScannerErroDigitalizarException("Erro ao carregar driver selecionado. Verifique se o driver pertence a um Scanner.");
}
TwUserInterface guif = new TwUserInterface();
guif.ShowUI = 1;
guif.ModalUI = 1;
guif.ParentHand = hwnd;
rc = DSuserif(appid, srcds, TwDG.Control, TwDAT.UserInterface, TwMSG.EnableDS, guif);
if (rc != TwRC.Success)
{
CloseSrc();
throw new ScannerErroDigitalizarException("Erro ao carregar driver selecionado. Verifique se o driver pertence a um Scanner.");
}
}
how to treat the same?
Reference: http://www.codeproject.com/Articles/1376/NET-TWAIN-image-scanner
You need to put more code to give more context, say which exception, indicate library documentation.
– Maniero
Edited by @bigown ...
– War Lock
@Warlock, am I mistaken or do you first try to import the image before loading the drivers? I noticed that after Try...catch has the driver instructions and at the end the error "Error .... " will not be reversed?
– Luiz Vichiatto
@Warlock command has worked?
– Ulysses Alves