←Select platform

Message Property

Summary
Gets a message that describes the current exception.

Syntax
C#
C++/CLI
Python
public override string Message { get; } 
public: 
property String^ Message { 
   String^ get() override; 
} 
Message # get  (WiaException) 

Property Value

The error message that explains the reason for the exception, or an empty string("").

Remarks

Overrides System.Exception.Message.

If this WiaException instance was initialized with a specific Code but no specific message, then this property will return the default error string that corresponds to the Code.

Get the error string that corresponds to any Code by calling the GetCodeMessage method.

Change the error string that corresponds to any Code by using the SetCodeMessage method.

Example
C#
using Leadtools; 
using Leadtools.Wia; 
 
       
public void WiaExceptionExample(IntPtr parent) 
{ 
   WiaSession wiaSession = null; 
 
   try 
   { 
      if (!WiaSession.IsAvailable(WiaVersion.Version1)) 
      { 
         Console.WriteLine("WIA version 1.0 not installed."); 
         return; 
      } 
 
      // initialize a new WIA wiaSession 
      wiaSession = new WiaSession(); 
      wiaSession.Startup(WiaVersion.Version1); 
 
      DialogResult res = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault); 
      if (res != DialogResult.OK) 
      { 
         Console.WriteLine("Error selecting WIA device."); 
         wiaSession.Shutdown(); 
         return; 
      } 
 
      // acquire a page, if paper jam, allow the user to retry 
      bool done = false; 
      while (!done) 
      { 
         try 
         { 
            wiaSession.AcquireEvent += new EventHandler<WiaAcquireEventArgs>(wiaSession_AcquireEvent2); 
 
            res = wiaSession.Acquire(parent, null, WiaAcquireFlags.ShowUserInterface | WiaAcquireFlags.UseCommonUI); 
            Console.WriteLine("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, propagate 
               throw ex; 
            } 
         } 
      } 
   } 
   catch (WiaException ex) 
   { 
      Console.WriteLine(string.Format("WIA error:{0}Code: {1}{0}Message: {2}", Environment.NewLine, ex.Code, ex.Message)); 
   } 
   catch (Exception ex) 
   { 
      Console.WriteLine(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; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Wia Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.