Problem: Achieving Dicom Server security in .NET using DicomObjects.COM (activeX) version

A QueryServer implemented as a windows service in .NET environment. When listen to a secured port using ListenSecure method of the DicomServer a COM Exception “Exception from HRESULT: 0x80010105 (RPC E SERVERFAULT)” is thrown.

To fix this problem, the entry point of the Windows service should be decorated with STAThread to force it to run in a single threaded apartment. Alternately, the method which does the server initialisation shall be decorated with “STAThread” attribute.

	// Entry Point for the Query Server
	public static void Main()
		... ...

Windows service generally runs under MTA and STA attribute being used only to initialise the service. However there will be other sporadic threading problems with callbacks using an ActiveX Component from windows service. Callbacks coming back to windows service which are MTA need to be marshalled to the STA thread. Hence Windows messages need to pumped and windows services are not able to pump the messages queue.

Alternate Solutions:

Move the entire Query server code to a winforms application which is designed for pumping windows messages. Instantiate the server from windows query service. Thus the Winforms application runs as a daemon.