I cannot help with debugging this issue, but I would recommend to consider using one of the open-source medical image visualization frameworks, such as 3D Slicer or MITK. These frameworks are developed specifically to make it easy to create new, custom applications. You don’t have to worry about implementing basic features, such as DICOM reading or 2D/3D display, but you can just focus on adding the features that are specific to your application.