NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Application manager returns a -17500 error from C# .NET code.

Solved!
Go to solution

Hi,

 

I'm trying to do a class that derives from a base class. The derived class is where all the TestStand stuff happens.

 

I've done in the past some custom UI and I usually start the project by dropping the TestStand UI Application Manager component on the form and start the application manager with myApplicationManager.Start(). I can then access the TS API.

 

However, this time, the Form (UI) doesn't contain the application manager since we don't want to make our GUI dependant of TestStand. The GUI calls function from the Controller base class which might call functions from the TestStand Controller.

 

I though I could simply do in our TestStand Controller class:        

 

private NationalInstruments.TestStand.Interop.UI.ApplicationMgr myApplicationMgr = new NationalInstruments.TestStand.Interop.UI.ApplicationMgr();

 

and call myApplicationMgr.Start()

 

When I do that, I received

System.Runtime.InteropServices.COMException was unhandled
  Message="Operation Failed."
  Source="TSUI.IApplicationMgr"
  ErrorCode=-17500

I'm not a veteran in C#, so I'm not sure if I can simply do this.

 

I tried also to create my own engine, but like many posts I read on the forum, it's a lot harder without the application manager. It seems I'll have a lot more things to handle going that way.

 

Any idea what could be wrong? Thank you.

 

I found those 2 posts somewhat related to my problem:

http://forums.ni.com/ni/board/message?board.id=330&message.id=22026&query.id=5965#M22026

http://forums.ni.com/ni/board/message?board.id=330&message.id=12797&query.id=5900#M12797

0 Kudos
Message 1 of 5
(4,683 Views)

Hi MatLaroche,

 

Components in the TestStand Interop UI assembly have only been tested in GUI threads. We have not tried to connect controls created in non-GUI threads and connect them to the Application Manager. Therefore, we cannot support interacting with a manager without placing an instance of the component on the form. 

 

Unfortunately, the alternative would therefore be to manage most of the operations yourself - such as initializing/shutting-down the TestStand Engine and logging in/out users.

Nestor
0 Kudos
Message 2 of 5
(4,631 Views)
Solution
Accepted by MatLaroche

The application manager is an ActiveX control. To create an ActiveX control dynamically in C# there is a bit more involved than what you are doing. You will need to do something more like the following (assuming that the 'this' object in this case is a class derived from the Windows Forms "Form" class, if not you will need add this code to some Form in your application as an ActiveX control must live on a Form):

 

        private NationalInstruments.TestStand.Interop.UI.Ax.AxApplicationMgr mApplicationManager;
        private void InitializeAndStartApplicationManager()
        {
            mApplicationManager = new NationalInstruments.TestStand.Interop.UI.Ax.AxApplicationMgr();
            ((System.ComponentModel.ISupportInitialize)(this.mApplicationManager)).BeginInit();
            //
            // mApplicationManager
            //
            this.mApplicationManager.Enabled = true;
            this.mApplicationManager.Location = new System.Drawing.Point(0, 0);
            this.mApplicationManager.Name = "mApplicationManager";
            this.mApplicationManager.Size = new System.Drawing.Size(32, 32);
            this.mApplicationManager.TabIndex = 1;
            // Other intitialization should go here, like adding events.
            // Example: this.mApplicationManager.ExitApplication += new System.EventHandler(this.mApplicationManager_ExitApplication);

            this.Controls.Add(this.mApplicationManager); // attach control to the form.
            ((System.ComponentModel.ISupportInitialize)(this.mApplicationManager)).EndInit();

 

 

            this.mApplicationManager.Start();
        }

 

 

Hope this helps,

-Doug

 

0 Kudos
Message 3 of 5
(4,590 Views)

Just want to add that another alternative is that you could put the application manager on its own form and when you want to use it create an instance of that form programmatically, but never show it (i.e. keep it hidden). That would give you the ability to customize the application manager settings using the designer rather than having to set them programmatically. Either way should work (this way or the one from my previous post).

 

Let me know if you have any questions or have trouble getting this working,

-Doug

 

0 Kudos
Message 4 of 5
(4,585 Views)

Thank you for your help both of you. I will update you later this week.

-mat

0 Kudos
Message 5 of 5
(4,572 Views)