Orthanc plugins in C#


I have been trying to create an Orthanc plugin in C#/.NET and so far I’ve had limited success. Limited as in I have managed to get the 4 main methods needed for a plugin to work and I’ve written to the log. However many questions need answer for this to work, specifically some of the structs used do not appear in the source code of the project (or at least I couldn’t find them with Visual Studio).

typedef struct _OrthancPluginWorklistQuery_t OrthancPluginWorklistQuery;

I have searched both for the _…_t and the other one and couldn’t find a definition with fields in it (so I can create it in C#). Further more when you need to call methods you need in C# to specify where it can find them (say SomeLibraby.dll with C exports say SomeFunction()).

Overall I think Orthanc is an amazing DICOM/PACS and its definitively what I’m searching for. My main hurdle will be to get worklists going, the sample plugin looks OK but I think it will be better if it had a REST api for adding/removing new items.


Thanks for your positive feedback.

To be fair, I have never considered the possibility of a C# assembly to implement the four entry points that are required by the C plugin SDK. This is actually a very interesting technical question. I am not expert enough in C#/.NET to know whether this is possible at all, so maybe someone else in this mailing list could give additional directions. The main difficulty will consist in wrapping the various callbacks as calls to C#. I suspect you will have to implement a C plugin that will “translate” the calls for the C# assembly.

All the structures that end with “…_t” are opaque data structures (following the PImpl design pattern). Concretely, they are “void*” pointers to C++ objects whose allocation/deallocation is handled by the Orthanc core (in other words, they can be considered as the “this” pointer in C++, after being casted to “void*”). Internally, the connection between a C plugin and the Orthanc core is handled by the following class:

Wrapping such opaque objects into C# would consist in casting their value to a “IntPtr”. Then, all the functions in the plugin SDK that refer to this opaque structure would be added as methods of the C# class. The destructor of the C# class would call the function that would free the structure, if any.

Regarding your question about adding REST API for adding/removing items in worklists, this topic has recently been lengthily discussed on the DebianMed mailing list:



I’ve created the above repository with my experimental code. Today I managed to get callbacks registering and firing (hello world sort of). What remains is learning how to construct proper replies and learning how to parse/process and reply to worklist requests.

With today’s work I’ve learned that the grunt of the work is being done by the Core orthanc services (InvokeService). Is there an overview document on how the worklist query from a SCU looks like and how it should be responded to. I can see that you convert the DICOM request to json and then use the json to check some stuff and then read back a .wl file as a result.

Great, this looks promising!

Regarding your questions about worklists, here are some references you might find useful (as an introduction to the DICOM PS3.4 standard):

http://forum.dcmtk.org/viewtopic.php?t=84 (this FAQ entry explains how to use the “wlmscpfs” tool that is included

The documentation of the Orthanc plugin framework for worklists is also available:

Progress update, trying to use the opaque structures in my C# plugin and I’ve hit a wall. I’m trying to find an example source file where the OrthancPluginOnStoredInstanceCallback callback is used in order to find the methods you use to work with the opaque structure. Could you point me in the right direction, so far I’ve found the DicomInstanceToStore class but I don’t think thats visible to the plugins framework, so basically where can I find some code that uses this opaque structure.