From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL-call and API-call from DLL that is called by TestStand

I've a rather complicated problem:
I've written a DLL (Visual C++) that is used by TestStand. This DLL (call it a.dll) gets its settings by calling another DLL (call it b.dll) which reads those settings from a database. This works fine, but a.dll uses a third party product (Altia Design) via an api. If I start a sequence which now calls a.dll the api-calls don't seem to work. I've written a little test application which is calling the same dll-functions and it works prefectly. All settings that are obtained via the b.dll are correct (checked it with the VC++ debugger).
Now some strange behavior: If I use the Edit function of my teststep, which calls the a.dll, and then start the sequence again it works. I can't fig
ure out where the problem is. All settings are in the database and are never part of teststand. Does my teststep which calls a.dll need to be changed? I think the problem is with teststand since the whole mechanism works fine with my test application.
0 Kudos
Message 1 of 3
(2,784 Views)
It might be that the Altia Design component needs to be called from a Single-Threaded Apartment. To test this, place the step that calls your DLL in a subsequence. In the call to the subsequence, select Multithreading and Remote Execution>>Run Sequence in a New Thread. Then click Settings... and checkmark Use Single-Threaded Apartment. To wait for your subsequence to complete and to retrieve its results, insert a Synchronization>>Wait step after the sequence call step, configure it to Wait for Thread, and select your sequence call step from the ring.

BTW, what errors are you getting?
0 Kudos
Message 2 of 3
(2,784 Views)
I tried your suggestions but unfortunately they didn't work. Are there any other ways to call a DLL function? Is there some in depth documentation about the DLL-Adapter and the way TestStand uses it? (I remember having some trouble calling a DLL that used an ActiveX -Control)
I get a user defined error code. The function that starts Altia returns zero, which means it didn't work. Not much information there I admit ;-( I tried to call the Altia function repeatedly with a break (2000ms) between each call but it didn't work)
0 Kudos
Message 3 of 3
(2,784 Views)