←Select platform

DicomException Class

Summary
The exception that is thrown when a LEADTOOLS DICOM error occurs.
Syntax
C#
VB
C++
Java
public class DicomException : LeadtoolsException 
Public Class DicomException  
   Inherits LeadtoolsException 
   Implements System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable  
public class DicomException extends LeadtoolsException 
public ref class DicomException : public LeadtoolsException, System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable   
Example
C#
VB
using Leadtools; 
using Leadtools.Dicom; 
 
 
public void TestLoadDicomDataset() 
{ 
   string dicomFileName = Path.Combine(LEAD_VARS.ImagesDir, "SomeBadFileName.dcm"); 
   //Make sure to initialize the DICOM engine, this needs to be done only once  
   //In the whole application 
   DicomEngine.Startup(); 
   using (DicomDataSet ds = new DicomDataSet()) 
   { 
      try 
      { 
         ds.Load(dicomFileName, DicomDataSetLoadFlags.None); 
      } 
      catch (DicomException ex) 
      { 
         //LEADTOOLS Dicom Error (the file can't be opened) 
         if (ex.Code == DicomExceptionCode.Open) 
            Console.WriteLine(string.Format("File {0} can't be opened", dicomFileName)); 
         else 
         { 
            //Some other LEADTOOLS Dicom Error 
            Console.WriteLine(string.Format("Could not load the file {0}.{1}Dicom error code: {2}{1}Message: {3}", dicomFileName, Environment.NewLine, ex.Code, ex.Message)); 
         } 
      } 
      catch (Exception ex) 
      { 
         // Other errors 
         Console.WriteLine(string.Format("Could not load the file {0}.{1}{2}", dicomFileName, Environment.NewLine, ex.Message)); 
      } 
   } 
   DicomEngine.Shutdown(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
} 
Imports Leadtools 
Imports Leadtools.Dicom 
 
Private Sub TestLoadDicomDataset() 
   Dim dicomFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "SomeBadFileName.dcm") 
   'Make sure to initialize the DICOM engine, this needs to be done only once  
   'In the whole application 
   DicomEngine.Startup() 
 
   Dim ds As DicomDataSet = New DicomDataSet() 
   Using (ds) 
      Try 
         ds.Load(dicomFileName, DicomDataSetLoadFlags.None) 
      Catch ex As DicomException 
         'LEADTOOLS Dicom Error (the file can't be opened) 
         If ex.Code = DicomExceptionCode.Open Then 
            MessageBox.Show(String.Format("File {0} can't be opened", dicomFileName)) 
         Else 
            'Some other LEADTOOLS Dicom Error 
            MessageBox.Show(String.Format("Could not load the file {0}.{1}Dicom error code: {2}{1}Message: {3}", dicomFileName, 
                                          Environment.NewLine, ex.Code, ex.Message)) 
         End If 
      Catch ex As Exception 
         ' Other errors 
         MessageBox.Show(String.Format("Could not load the file {0}.{1}{2}", dicomFileName, Environment.NewLine, ex.Message)) 
      End Try 
   End Using 
 
   DicomEngine.Shutdown() 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images" 
End Class 
Requirements

Target Platforms

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

Leadtools.Dicom Assembly

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