Can not use DicomObjects.NET in Visual Studio 2010

Problem Description

Sometimes people are facing the problem of using DicomObjects .NET version in Visual Studio 2010 due to error "DicomObjects is not decalred. It may be inaccessible due to its protection level".

Run DicomObjects.NET Based 32-bit Application under 64-bit Windows

DicomObjects.NET, including all codecs are now native code, and should run equally well under 64-bit Windows as under 32-bit versions, using the AnyCPU option.

If you need to force 32 bit mode (e.g. if you need the Acrobat display otpion, which is 32 bit only), then you should make the following change to force your application to run in 32-bit mode under 64-bit Windows.

Open up project properties and click the Compile:

Config File

As of Version 5.6 of the .NET version a config file is available to allow some aspects of DicomObjects behaviour to be modified without the need to recompile. This is broadly equivalent to the registry as used in the COM version, but has the advantage of being application-specific, avoiding any side-effects for other applications.

Deleting or Over-writing Files Which have been Read using ReadFile

Image files which have been read by DicomObjects using ReadFile cannot normally be deleted (or over-written using WriteFile etc.) until the file is released. This is because memory mapping is enabled (Default DicomObjects's behaviour), causing only the data actually needed at any time to be read into memory. This requires that the file be locked whilst the associated image object exists.

You can use one of the following three methods to solve this problem:

Pixel Data to Byte Array

We are often asked how to retrieve the pixel data of a DicomImage into a Byte array. The following code will load an image and copy the pixel data into a byte array.

Limiting Transfer Syntax for RT SOP Classes

There is a known issue in the Dicom Standard. SOP classes related to RT can legitimately be write / transferred using several different Transfer Syntaxes. HOWEVER The length of some of the attributes associated to RT is such that they can not be represent within a 32 bit word. As such it is imposable to represent them using an explicit Transfer Syntax.

Therefore it is often appropriate to limit these SOP classes so that they can only use Implicit VR Little-endian (1.2.840.10008.1.2)

Initialising an image to the viewer size (stretch and scroll)

It is often useful to zoom and scroll an image to fill the viewer. The quick way of doing this is by using StretchMode method i.e.

MemoryMapping in Reading Files

There are two ways to control how DicomObjects reads files in terms of efficiency and RAM usage:

  • Setting DicomGlobal.CloseFilesAfterReading
  • Seting DicomGlobal.SetRegWord("DisableMemoryMapping", VALUE)

If you want DicomObjects to read the entire content of the file so that it loses the file handle and you have total control over the file after reading (you can modify or even delete the file), you set either CloseFilesAfterReading to true or DisableMemoryMapping to 1 (replace VALUE by 1).

Secure Connection with DVT Simulator

If you are testing DicomObjects's Secure Connection Functionalities and wish you to use DVT simulator as the tester, then it is very easy to do so as long as you have the DVT-trusted ".p12" file (we are using the one that comes with DVT here):

Dim sec As New DicomServerSecurity
Dim CertBytes As Byte() 
CertBytes = System.IO.File.ReadAllBytes("C:\Program Files\DVT\certificates\SutSelfSigned.p12")
sec.Certificate = New X509Certificate2(CertBytes, "dvt")
sec.ClientAuthentication = False
server.Listen(104, sec)  ' server is a DicomServer object


Subscribe to RSS - .NET