COM Interop and .Net

The HL7Connect API is published to the DotNet platform as a COM Automation server using DotNet Interop. There's a variety of subtle and difficult problems associated with using COM automation servers in .Net (IStream/Stream aliasing issues, COM reference counting, case conversion problems, and loss of inheritence and documentation to name the more important). As a consequence, HL7Connect provides a set of DotNet wrapper classes that hide these issues from the user.

HL7Connect is distributed with 3 DotNet related resources:

  1. HL7Connect.Interop.dll
    This is the base COM import

  2. HL7Connect.API.dll
    This is the generated set of wrapper classes documented here.

  3. HL7ConnectAPI.cs
    The source for HL7Connect.API.dll for reference.

Using the HL7Connect API in .Net

To use the HL7Connect API, add a reference to both HL7Connect.Interop.dll and HL7Connect.API.dll to your project(s) in Visual Studio. Then you can use the classes in the HL7Connect namespaces below

Memory Management

DotNet languages include garbage collection, so you don't have free up your memory when you're done with it. Unfortunately, it's not quite so simple because of COM. The reason for this is to do with COM/DotNet reference counting. DotNet objects hang around until the garbage collector gets around to them - which it does with considerable reluctance. As long as that object hangs around, the COM object hangs around too.

This leads to two problems:

So, either call GC.Collect() regularly, and/or use HL7Connect.Utils.Base.ReleaseCOM(Obj) for any of the API objects when you're done with them.

Dot Net Namespaces

HL7Connect.InteropThe COM wrapper layer. All enums are in this namespace, since they are declared directly by COM
HL7Connect.V2The HL7 V2 Messaging Object Model
HL7Connect.CdaThe CDA Object Model
HL7Connect.CcdThe CCD Builder Module
HL7Connect.EventsThe events for which scripts or COM implementations may be invoked
HL7Connect.ExchangeTypes concerned with message and document exchange using COM
HL7Connect.KernelKernel Types - only when using Internal COM mode
HL7Connect.UcumUcum (Units of Measure) services.
HL7Connect.DocDocument services (format conversion, printing).
HL7Connect.ServicesBasic Entry points by which HL7Connect provides services to other applications.
HL7Connect.UtilsUtility classes - not expected to have application outside the interface library itself

© Kestral Computing P/L 2000-2010.
Keywords: DLL, C#, DotNet, PIA, Interop, Namespaces, Memory Management, Leak