←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  (TwainException) 

Property Value

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

Remarks

Overrides Message.

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

You can get the error string that corresponds to any Code through the GetCodeMessage method.

You can change the error string that corresponds to any Code through the SetCodeMessage method.

Example
C#
using Leadtools; 
using Leadtools.Twain; 
 
 
public void _twainSession_AcquirePage(object sender, TwainAcquirePageEventArgs e) 
{ 
   Application.DoEvents(); 
 
   if (e.Image != null) 
      e.Image.Dispose(); 
 
   e.Cancel = false; 
} 
public void TwainExceptionExample(IntPtr parent) 
{ 
   TwainSession session = null; 
 
   try 
   { 
      // initialize a new TWAIN session 
      session = new TwainSession(); 
      session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None); 
      session.AcquirePage += new EventHandler<TwainAcquirePageEventArgs>(_twainSession_AcquirePage); 
 
      // acquire a page, if paper jam, allow the user to retry 
      bool done = false; 
      while (!done) 
      { 
         try 
         { 
            DialogResult res = session.Acquire(TwainUserInterfaceFlags.Modal | TwainUserInterfaceFlags.Show); 
            MessageBox.Show("Success"); 
            done = true; 
         } 
         catch (TwainException ex) 
         { 
            if (ex.Code == TwainExceptionCode.PaperJam) 
            { 
               if (MessageBox.Show("Paper jam.  Fix and retry?", "TWAIN", MessageBoxButtons.YesNo) == DialogResult.No) 
                  done = true; 
            } 
            else 
            { 
               // other error, propogate 
               throw ex; 
            } 
         } 
      } 
   } 
   catch (TwainException ex) 
   { 
      MessageBox.Show(string.Format("Twain 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 (session != null) 
         session.Shutdown(); 
   } 
} 
Requirements

Target Platforms

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

Leadtools.Twain Assembly

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