LEADTOOLS Image File Support (Leadtools.Codecs assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
ThrowExceptionsOnInvalidImages Property
See Also 
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);
}

Property 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()
   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()
End Sub
C#Copy Code
public void ThrowExceptionsOnInvalidImagesExample()
{
   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();
}
SilverlightCSharpCopy Code
public void ThrowExceptionsOnInvalidImagesExample(Stream inStream)
{
   RasterCodecs codecs = new RasterCodecs();
   // enable codec exceptions
   codecs.ThrowExceptionsOnInvalidImages = true;
   try
   {
      RasterImage image = codecs.Load(inStream); //some non-image file
   }
   catch
   {
      Debug.WriteLine("exception caught - sample sucess");
   }
}
SilverlightVBCopy Code
Public Sub ThrowExceptionsOnInvalidImagesExample(ByVal inStream As Stream)
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' enable codec exceptions
   codecs.ThrowExceptionsOnInvalidImages = True
   Try
      Dim image As RasterImage = codecs.Load(inStream) 'some non-image file
   Catch
      Debug.WriteLine("exception caught - sample sucess")
   End Try
End Sub

Remarks

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

Set ThrowExceptionsOnInvalidImages to false to cause the RasterCodecs.Load or RasterCodecs.LoadAsync methods 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: Silverlight, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also