02-25-2013 06:14 AM
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é
02-25-2013 08:52 AM - edited 02-25-2013 08:52 AM
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.
02-25-2013 09:52 AM
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
02-28-2013 06:49 AM
Hi
were you able to solve this issue?
Are you using a shipping process model? If not, try one. They should be leak proof.
03-05-2013 02:23 AM
Hi,
sorry for the late answer.
I put the Applikation Manager on the Form. But there a error occurs.
How i can register the ActiveX?
René
03-05-2013 10:19 AM - edited 03-05-2013 10:22 AM
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