LEADTOOLS WIA (Leadtools.Wia assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
SetCodeMessage Method
See Also 
Leadtools.Wia Namespace > WiaException Class : SetCodeMessage Method



code
A WiaExceptionCode value for which the error string is being set.
message
A System.String that contains the new message for code.
code
A WiaExceptionCode value for which the error string is being set.
message
A System.String that contains the new message for code.
Sets the error string that corresponds to a specific WiaExceptionCode.

Syntax

Visual Basic (Declaration) 
Public Shared Sub SetCodeMessage( _
   ByVal code As WiaExceptionCode, _
   ByVal message As String _
) 
Visual Basic (Usage)Copy Code
Dim code As WiaExceptionCode
Dim message As String
 
WiaException.SetCodeMessage(code, message)
C# 
public static void SetCodeMessage( 
   WiaExceptionCode code,
   string message
)
C++/CLI 
public:
static void SetCodeMessage( 
   WiaExceptionCode code,
   String^ message
) 

Parameters

code
A WiaExceptionCode value for which the error string is being set.
message
A System.String that contains the new message for code.

Example

Visual BasicCopy Code
<Test> _
Public Sub SetCodeMessageExample()
   ' Get the initial FileFormat message
   Dim code As WiaExceptionCode = WiaExceptionCode.PaperEmpty
   Dim message As String = WiaException.GetCodeMessage(code)
   MessageBox.Show(String.Format("Code: {0}, message: {1}", code, message))
   ' make sure that this message is used now
   Try
      Throw New WiaException(code)
   Catch ex As Exception
      MessageBox.Show(ex.Message)
   End Try

   ' change this message to a custom one
   WiaException.SetCodeMessage(code, "My new message")

   ' make sure that this new message is used now
   Try
      Throw New WiaException(code)
   Catch ex As Exception
      MessageBox.Show(ex.Message)
   End Try
End Sub
C#Copy Code
public void SetCodeMessageExample()
{
   // Get the initial FileFormat message
   WiaExceptionCode code = WiaExceptionCode.PaperEmpty;
   string message = WiaException.GetCodeMessage(code);
   MessageBox.Show(string.Format("Code: {0}, message: {1}", code, message));

   // make sure that this message is used now
   try
   {
      throw new WiaException(code);
   }
   catch(Exception ex)
   {
      MessageBox.Show(ex.Message);
   }

   // change this message to a custom one
   WiaException.SetCodeMessage(code, "My new message");

   // make sure that this new message is used now
   try
   {
      throw new WiaException(code);
   }
   catch(Exception ex)
   {
      MessageBox.Show(ex.Message);
   }
}

Remarks

By default, WiaException has a string message for each WiaExceptionCode. You can get this message by using the GetCodeMessage method. Also, you can change any string message for any WiaExceptionCode by using the SetCodeMessage method.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also