NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

csharp teststand 3.5

Hello,

 

I have a little problem to call Teststand 3.5 from visualstudio 2010 with c#.

 

I tried with the following Code:

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

// TestStand Core API 
using NationalInstruments.TestStand.Interop.API;

// TestStand User Interface Controls
using NationalInstruments.TestStand.Interop.UI;
using NationalInstruments.TestStand.Interop.UI.Support;


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            NationalInstruments.TestStand.Interop.UI.ApplicationMgr tsmgr = new NationalInstruments.TestStand.Interop.UI.ApplicationMgr();
            NationalInstruments.TestStand.Interop.UI.SequenceFileViewMgr tssfmgr = new NationalInstruments.TestStand.Interop.UI.SequenceFileViewMgr();



            try
            {
                tsmgr.LoginOnStart = false;
                //Must set user then Start, otherwise only Start will not work.
                User userToLogIn = tsmgr.GetEngine().GetUser("administrator");
                tsmgr.GetEngine().CurrentUser = tsmgr.GetEngine().GetUser("administrator");
                tsmgr.Start();

                tsmgr.OpenSequenceFile(@"c:\Projekte\Testplan\TS1.seq").GetSequence(0);

                tsmgr.GetCommand(CommandKinds.CommandKind_ExecutionEntryPoints_Set, 0);

                tsmgr.CloseSequenceFile(tssfmgr.SequenceFile);


            }
            catch (COMException exp)
            {

                MessageBox.Show("Error " + exp.ErrorCode.ToString() + ": " + exp.Message);
            }
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}

 

The only Error which occoured is "Error -17500: Ausnahme von HRESULT: 0xFFFFBBA4" on the Line with

  tsmgr.Start();


Which is the correct approach to start Teststand?

 

King regards,

 

René

0 Kudos
Message 1 of 6
(4,273 Views)

Have you tried the user interface examples that ship with teststand?

If not, look at the following example. C:\Users\Public\Documents\National Instruments\TestStand <version>\UserInterfaces\Simple\CSharp

This is always a good starting point.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 2 of 6
(4,263 Views)

You should probably put the controls (application manager and sequence view manager) directly on the form rather than trying to create them dynamically. ActiveX controls need to be associated with a window and the easiest way to do that is to use the form designer in visual studio. You should have a TestStand palette from which you can drag them onto your form.

 

Hope this helps,

-Doug

0 Kudos
Message 3 of 6
(4,255 Views)

Hi

 

were you able to solve this issue?

Are you using a shipping process model?  If not, try one.  They should be leak proof.  

0 Kudos
Message 4 of 6
(4,218 Views)

Hi,

 

sorry for the late answer.

I put the Applikation Manager on the Form. But there a error occurs.

 

vs2010error.jpg

 

How i can register the ActiveX?

 

René

0 Kudos
Message 5 of 6
(4,186 Views)

Make sure the platform of your exe project is set to x86 rather than AnyCPU. If the sequence editor is working then the controls should already be registered properly so that's probably not the problem. If your exe project is set to AnyCPU and you are on a 64-bit OS it will be looking for 64-bit versions of the activeX controls (which do not exist), so you need to use x86 instead.

 

You might also be having problems due to using the Express version of Visual Studio. I'm not sure if that version supports the control palettes that teststand adds to visual studio. Where did you get the application manager from?

 

 

Hope this helps,

-Doug

0 Kudos
Message 6 of 6
(4,176 Views)