Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
ThrowExceptionsOnInvalidImages Property
See Also  Example
Leadtools.Codecs Namespace > RasterCodecs Class : ThrowExceptionsOnInvalidImages Property



Gets or sets a value indicating whether to throw an exception instead of returning a null reference (Nothing in Visual Basic) on certain methods of this RasterCodecs object.

Syntax

Visual Basic (Declaration) 
Public Property ThrowExceptionsOnInvalidImages As Boolean
Visual Basic (Usage)Copy Code
Dim instance As RasterCodecs
Dim value As Boolean
 
instance.ThrowExceptionsOnInvalidImages = value
 
value = instance.ThrowExceptionsOnInvalidImages
C# 
public bool ThrowExceptionsOnInvalidImages {get; set;}
C++/CLI 
public:
property bool ThrowExceptionsOnInvalidImages {
   bool get();
   void set (bool value);
}

Return Value

A value indicating whether to throw an exception instead of returning a null reference (Nothing in Visual Basic) on certain methods of this RasterCodecs object.

Example

Visual BasicCopy Code
Public Sub ThrowExceptionsOnInvalidImagesExample()
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()

   ' enable codec exceptions
   codecs.ThrowExceptionsOnInvalidImages = True
   Try
      Dim image As RasterImage = codecs.Load("some non-image file")
   Catch
      Console.WriteLine("exception caught - sample sucess")
   End Try

   ' Clean up
   codecs.Dispose()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void ThrowExceptionsOnInvalidImagesExample() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // enable codec exceptions 
   codecs.ThrowExceptionsOnInvalidImages = true; 
   try 
   { 
      RasterImage image = codecs.Load("some non-image file"); 
   } 
   catch 
   { 
      Console.WriteLine("exception caught - sample sucess"); 
   } 
 
   // Clean up 
   codecs.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Remarks

Some of the methods of this RasterCodecs class will return an object when called. For example, the RasterCodecs.Load(String) method will return the RasterImage object created. If the value of ThrowExceptionsOnInvalidImages is set to true, then when the RasterCodecs.Load(String) method encounters an error and cannot return a valud image, it will throw an appropriate exception.

Set ThrowExceptionsOnInvalidImages to false to cause the RasterCodecs.Load(String) method to return a null reference (Nothing in Visual Basic) instead when it encounters an error and cannot return a valud image

The following methods will either throw an exception or return a null reference (Nothing in Visual Basic) depending on the setting of the ThrowExceptionsOnInvalidImages property.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also