The exception that is thrown when a WIA error occurs.
[SerializableAttribute()]public class WiaException : Leadtools.LeadtoolsException, System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable
<SerializableAttribute()>Public Class WiaExceptionInherits Leadtools.LeadtoolsExceptionImplements System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable
[SerializableAttribute()]public ref class WiaException : public Leadtools.LeadtoolsException, System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable
The WiaException class defines a Code property that you can examine to determine what caused the error.
Default messages are implemented for each Code. You can, however, modify any message by using the GetCodeMessage and SetCodeMessage methods.
Imports LeadtoolsImports Leadtools.Wia<Test> _#If Not LEADTOOLS_V19_OR_LATER ThenPublic Sub WiaExceptionExample(ByVal parent As IWin32Window)#ElsePublic Sub WiaExceptionExample(ByVal parent As IntPtr)#End If ' #If LEADTOOLS_V19_OR_LATER ThenDim wiaSession As WiaSession = NothingTryIf (Not WiaSession.IsAvailable(WiaVersion.Version1)) ThenMessageBox.Show("WIA version 1.0 not installed.")ReturnEnd If' initialize a new WIA wiaSessionwiaSession = New WiaSession()wiaSession.Startup(WiaVersion.Version1)Dim res As DialogResult = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault)If res <> DialogResult.OK ThenMessageBox.Show("Error selecting WIA device.")wiaSession.Shutdown()ReturnEnd If' acquire a page, if paper jam, allow the user to retryDim done As Boolean = FalseDo While Not doneTryAddHandler wiaSession.AcquireEvent, AddressOf wiaSession_AcquireEvent2res = wiaSession.Acquire(parent, Nothing, WiaAcquireFlags.ShowUserInterface Or WiaAcquireFlags.UseCommonUI)MessageBox.Show("Success")done = TrueRemoveHandler wiaSession.AcquireEvent, AddressOf wiaSession_AcquireEvent2Catch ex As WiaExceptionIf ex.Code = WiaExceptionCode.PaperJam ThenIf MessageBox.Show("Paper jam. Fix and retry?", "WIA", MessageBoxButtons.YesNo) = DialogResult.No Thendone = TrueEnd IfElse' other error, propagateThrow exEnd IfEnd TryLoopCatch ex As WiaExceptionMessageBox.Show(String.Format("WIA error:{0}Code: {1}{0}Message: {2}", Environment.NewLine, ex.Code, ex.Message))Catch ex As ExceptionMessageBox.Show(String.Format("Other error: Message:{0}", ex.Message))FinallyIf Not wiaSession Is Nothing ThenwiaSession.Shutdown()End IfEnd TryEnd SubPrivate Sub wiaSession_AcquireEvent2(ByVal sender As Object, ByVal e As WiaAcquireEventArgs)Application.DoEvents()If Not e.Image Is Nothing Thene.Image.Dispose()End Ife.Cancel = FalseEnd Sub
using Leadtools;using Leadtools.Wia;[TestMethod]#if !LEADTOOLS_V19_OR_LATERpublic void WiaExceptionExample(IWin32Window parent)#elsepublic void WiaExceptionExample(IntPtr parent)#endif // #if !LEADTOOLS_V19_OR_LATER{WiaSession wiaSession = null;try{if (!WiaSession.IsAvailable(WiaVersion.Version1)){MessageBox.Show("WIA version 1.0 not installed.");return;}// initialize a new WIA wiaSessionwiaSession = new WiaSession();wiaSession.Startup(WiaVersion.Version1);DialogResult res = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault);if (res != DialogResult.OK){MessageBox.Show("Error selecting WIA device.");wiaSession.Shutdown();return;}// acquire a page, if paper jam, allow the user to retrybool done = false;while(!done){try{wiaSession.AcquireEvent += new EventHandler<WiaAcquireEventArgs>(wiaSession_AcquireEvent2);res = wiaSession.Acquire(parent, null, WiaAcquireFlags.ShowUserInterface | WiaAcquireFlags.UseCommonUI);MessageBox.Show("Success");done = true;wiaSession.AcquireEvent -= new EventHandler<WiaAcquireEventArgs>(wiaSession_AcquireEvent2);}catch(WiaException ex){if(ex.Code == WiaExceptionCode.PaperJam){if(MessageBox.Show("Paper jam. Fix and retry?", "WIA", MessageBoxButtons.YesNo) == DialogResult.No)done = true;}else{// other error, propagatethrow ex;}}}}catch(WiaException ex){MessageBox.Show(string.Format("WIA error:{0}Code: {1}{0}Message: {2}", Environment.NewLine, ex.Code, ex.Message));}catch(Exception ex){MessageBox.Show(string.Format("Other error: Message:{0}", ex.Message));}finally{if(wiaSession != null)wiaSession.Shutdown();}}void wiaSession_AcquireEvent2(object sender, WiaAcquireEventArgs e){Application.DoEvents();if (e.Image != null)e.Image.Dispose();e.Cancel = false;}
|
Products |
Support |
Feedback: WiaException Class - Leadtools.Wia |
Introduction |
Help Version 19.0.2017.3.21
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.