Skip to content
  • There are no suggestions because the search field is empty.

I am trying to load a DLL into the Gamma Scripting Engine of DataHub

I am trying to load a DLL into the Gamma Scripting Engine of DataHub.  I used the following to load the DLL.

DllLoad ("C:\\Program Files\\Cogent\\Cogent DataHub\\dll\\<DLL Name>");

How can I interact with that DLL in DataHub scripting?

The problem is that I haven’t been able to call or use any of the methods of the DLL, all I get is the error message:

Expression does not evaluate to a function

It's not that simple. You cannot simply load any DLL into Gamma; the DLL must be specially constructed to interact with the Gamma engine. The reason for this is that the scripting engine needs to be able to perform a run-time conversion between the data types in the DLL and the data types used in the scripting language. The scripting engine also needs to be informed how to manage the memory for pointer types used by the DLL. Further, the scripting engine must call the functions in the DLL using the correct calling convention defined by the DLL.

All of this considerations usually require "wrapping" the DLL functions within functions that present predictable calling conventions, data types and memory semantics to the scripting engine. Normally we perform this work on behalf of our customers.

The dlmethod and dlfunc calls will only work if you know in advance that the calling convention of the function in the DLL matches the calling convention expectations of the Gamma engine. This is only really assured if you have created the DLL specially for the purpose. MS-Windows libraries can be compiled with several different calling conventions, so it is not possible to predict which convention is being used by any particular function within a DLL. Linux libraries are more predictable and have a much higher chance of success.

The above applies to unmanaged C and C++ DLLs. DataHub is a native C++ application, so it cannot load a managed DLL. If you want to use .NET languages with DataHub, the choices are to use the .NET API and communicate with DataHub via a TCP socket, or use OPC to communicate with the DataHub using COM. In either case, the .NET application is an independent program, not a Gamma extension.