Using COM & .NET versions in the same project

In order to make life easier and quicker for those doing project conversions, it was decided to use the same basic object names in the .NET_version as had been used in COM, but this does make life difficult if anyone wishes to use both in the same project. In general, we would not recommend this, but recognise that it might occasionally be necessary. This then is a short guide to the steps needed if you do wish to use the COM & .NET versions of DicomObjects in the same project.

Use C#
Unfortunately, VB.NET seems to lack the aliasing feature mentioned below. If you know better, and find out how to do it, then please let us know and/or edit this article (yes, anyone is welcome to do so!)
Add both sets of references
Using normal mechanisms - either explicit adding of the references, or dragging a DicomViewer (COM or .NET) onto a form
Give the .NET version an alias
3 steps
  • Go to solution explorer
  • Click on the DicomObjects.NET.x.x reference (not the COM one(s)) and view its properties
  • Changes the Aliases property from global to something else - e.g. DicomObjectsNET
Create an extern reference
Add an extern alias line at the top of your source file (above existing "uses" statements) referencing the alias you gave in the previous step - e.g.
extern alias DicomObjectsNET;
Use the fully qualified name when referencing .NET objects
You need the form alias.DicomObjects.class - e.g.
DicomObjectsNET.DicomObjects.DicomImage y =
 new DicomObjectsNET.DicomObjects.DicomImage();
Or make things simpler with a 'using' alias
This makes the above less of a typing ordeal - e.g.
extern alias DicomObjectsNET;
using DoNET = DicomObjectsNET.DicomObjects;
...
   DoNET.DicomImage y = new DoNET.DicomImage;

Finally, please note that although this mechanism allows both forms of DicomObjects to be used in the same project, they are not programmatically equivalent, and you cannot for instance cast from one to the other, as the underlying representations are utterly different.

Relevance: