NI TestStand

Showing results for 
Search instead for 
Did you mean: 

C# .Net application - Run MainSequence using api

Go to solution




I'm in charge of developping a software in C# .Net using TestStand API, like this example program : C:\Users\Public\Documents\National Instruments\<TestStand version>\Examples\TestStand API\Executing Sequences Using API\DotNet \.

When I call one sequence, it works.

Now, I need to execute a sequence file .seq, as it is done in the example program C:\Users\Public\Documents\National Instruments\<TestStand version>\Examples\Modifying User Interfaces\Creating a Basic User Interface\DotNet.

I need to create a button like the one called in the example (see the image above, the button is yellow-colored).

In this NI C# code, this is not the same logic as in Executing Sequences Using API.


  • My question is, could you explain to me how to get the same result as in Creating a Basic User Interface, but the same way Executing Sequences Using API is written ?


Thanks you very much !

0 Kudos
Message 1 of 9

The button you are referring to is meant to execute the active sequence without a process model.

This is why the command connections differ from the ones when using prodess models




Message 2 of 9

All right, I thought there would be another way to do this 😞 .

Thank you for your explanation !

0 Kudos
Message 3 of 9

Hi, brother, I've read your question.


       You can use three methods to complete this task:


       Method 1:

             Like the image and path in your example, that example actually uses the ActiveX control provided by NI to implement it. What you need to do:

                  1. Reference the required dll in C #, as shown in the following figure


                  2. Add NI controls in the COM component on the left toolbar, and then select the desired controls to place on the form


                  3. Add the corresponding event response to the control.

                 The code is similar to:

axSequenceFileViewMgr.ConnectCommand(axRunSelectedButton, CommandKinds.CommandKind_RunCurrentSequence, 0, CommandConnectionOptions.CommandConnection_NoOptions);

                 So, actually, Oli_Wachno's reply on the second floor was right, but he didn't explain it in more detail (I guess he probably thought you should have more experience)


      Method 2:

            Reference the basic axApplicationMgr control, and then use C# native controls for other controls. You add a button, and the code should look like this:

if (axSequenceFileViewMgr.SequenceFile != null)
    axSequenceFileViewMgr.GetCommand(CommandKinds.CommandKind_ExecutionEntryPoints_Set, 0).Execute(true);
    MessageBox.Show("You must open a sequence file before you can execute.");

           If you need more details, please refer to: <NI Public Folder> \ Examples \ Modifying User Interfaces \ Building a TestStand UI with Native Controls


        Method 3:

              Instead of using NI controls, directly instantiate the NI engine to load the sequence file and run it. At this point, your code should look similar to:

string strEntryPoint = "Test UUTs";              //"Single Pass"; //"Run MainSequence";
Sequence sequence = seqFileModel.GetSequenceByName(strEntryPoint);
Execution execution = engine.NewExecution(sequenceFile, strEntryPoint, seqFileModel, false, 0, null, null, null); 
bool Execution_Result = execution.WaitForEndEx(-1, true, null, null);
MessageBox.Show($"Execution Result: {Execution_Result}");


Message 4 of 9



Thank you very much ! I have not been working on TestStand software for long, so the details are very helpful indeed !

I'm working on it today, hopefully I will get it work 🙂

0 Kudos
Message 5 of 9



The second method appears most relevant for my program.

To really simplify, I tried this :



The thing is, I have a problem on my third line, the set of SequenceFile.


I tried only to create my AxSequenceFileViewMgr in the C# button click method, in order not to touch to the rest of the program, but perhaps I should have initialized it in the form as in the NI example program Building a TestStand UI with Native Controls ?

0 Kudos
Message 6 of 9
Accepted by topic author IsMu

oh,Let me give you a simple example of how this works, this is what I call method 2.

Message 7 of 9

Thanks, this is great !

Starting from your program "method 2", how would you "hide" the path to the file ? I need it to be hidden from the is possible to give the path in the C# code, directly ?

0 Kudos
Message 8 of 9

Thank you VERY MUCH for your help, I managed to make things work 🙂 !

0 Kudos
Message 9 of 9