Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.17
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;}
Managed Extensions for C++ 
public: __property bool get_ThrowExceptionsOnInvalidImages();
public: __property void set_ThrowExceptionsOnInvalidImages( 
   bool value
);
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
RasterCodecs.ThrowExceptionsOnInvalidImages
      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
RasterCodecs.ThrowExceptionsOnInvalidImages 
      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 Load method will return the RasterImage object created. If the value of ThrowExceptionsOnInvalidImages is set to true, then when the Load method encounters an error and cannot return a valud image, it will throw an appropriate exception.

Set ThrowExceptionsOnInvalidImages to false to cause the Load 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 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also