LEADTOOLS Medical (Leadtools.Dicom assembly)
LEAD Technologies, Inc

DicomException Class

Example 







Members 
The exception that is thrown when a LEADTOOLS DICOM error occurs. .NET support WinRT support Silverlight support
Object Model
DicomException Class
Syntax
'Declaration
 
Public Class DicomException 
   Inherits Leadtools.LeadtoolsException
   Implements System.Runtime.InteropServices._ExceptionSystem.Runtime.Serialization.ISerializable 
'Usage
 
Dim instance As DicomException
public sealed class DicomException : System.Runtime.InteropServices._Exception~Remove~  
ObjectiveC Syntax
Java Syntax
function Leadtools.Dicom.DicomException()
Example
Copy CodeCopy Code  
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:\Users\Public\Documents\LEADTOOLS Images"
End Class
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)
               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));
            }
         }
         catch (Exception ex)
         {
            // Other errors
            MessageBox.Show(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:\Users\Public\Documents\LEADTOOLS Images";
}
public void TestLoadDicomDataset(Stream stream)
{
   //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(stream, DicomDataSetLoadFlags.None);
      }
      catch (DicomException ex)
      {
         //LEADTOOLS Dicom Error (the file can't be opened)
         if (ex.Code == DicomExceptionCode.Open)
            MessageBox.Show(string.Format("Stream can't be opened"));
         else
         {
            //Some other LEADTOOLS Dicom Error
            MessageBox.Show(string.Format("Could not load the stream{0}Dicom error code: {1}{0}Message: {2}", Environment.NewLine, ex.Code, ex.Message));
         }
      }
      catch (Exception ex)
      {
         // Other errors
         MessageBox.Show(string.Format("Could not load the stream.{0}{1}", Environment.NewLine, ex.Message));
      }
   }
   DicomEngine.Shutdown();
}
Public Sub TestLoadDicomDataset(ByVal stream As Stream)
   'Make sure to initialize the DICOM engine, this needs to be done only once 
   'In the whole application
   DicomEngine.Startup()
   Using ds As DicomDataSet = New DicomDataSet()
      Try
         ds.Load(stream, 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("Stream can't be opened"))
         Else
            'Some other LEADTOOLS Dicom Error
                  MessageBox.Show(String.Format("Could not load the stream{0}Dicom error code: {1}{0}Message: {2}", _
                                                Environment.NewLine, ex.Code, ex.Message))
         End If
      Catch ex As Exception
         ' Other errors
         MessageBox.Show(String.Format("Could not load the stream.{0}{1}", Environment.NewLine, ex.Message))
      End Try
   End Using
   DicomEngine.Shutdown()
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DicomException Members
Leadtools.Dicom Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Dicom requires a Medical toolkit server license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features