NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using GetResourceString in VB .NET

Hello,

I am trying to write a VB .NET Assembly that will be called as a SubStep for a custom step type. It will be used to configure the step.
I want to make my VB .NET form language aware, and as such I'd like to use the GetResourceString method of the TestStand Engine object.

I have exposed the following subroutine that gets called by TestStand for the SubStep:
Public Sub Edit_TrueFalse(ByVal objSeqContext As NationalInstruments.TestStand.Interop.API.SequenceContext)

Then in the code to set various strings to their correct language I do the following:
ExampleLabel.Text = objSeqContext.Engine.GetResourceString(, )

The works perfectly fine and my form is displayed with the correct strings from the language ini file. The problem is that when you try to quit the SequenceEditor, the main form closes but the process is left running and never terminates. The process is left running, and is consuming around 40megs. I have also tried the same code but with any lines using GetResourceString commented out and in this case the SequenceEditor terminates correctly.

There are some messy workarounds to this problem, but I'd rather get the above working if possible.

Any ideas?
Cheers.
0 Kudos
Message 1 of 7
(4,499 Views)
Grefyne -
What version of TestStand are you using? I do not know why the process would not shutdown. If you are willing to create a simple example step type with the substep source and a sequence that uses it, I could take a look at why TestStand does not shutdown fully.
Scott Richardson
https://testeract.com
0 Kudos
Message 2 of 7
(4,471 Views)
Hi Scott,

I have created a simple example step type in VB .NET 2003. I have attached the zip to this message, which needs to be unzipped with subdirs to C: (the example sequence has hard coded paths)

I am using the following software:
Microsoft Visual Studio .NET 2003
Microsoft .NET Framework 1.1 SP1
National Instruments TestStand v3.1

Many thanks for looking at this problem.

One additional question, how do I flag to TestStand that when a setup value has been changed that the sequence file has change - meaning the user will be prompted on exit if they want to save changes.

Kind regards,
Ian Barnes
0 Kudos
Message 3 of 7
(4,460 Views)
Ian -
Just wanted to let you know that there is a developer that will look at your files to see if we can reproduce it.
Scott Richardson
https://testeract.com
0 Kudos
Message 4 of 7
(4,437 Views)
Ian

Add a call to GC.Collect() after you set all of your variables to nothing. This will force the garbage collector to release the reference to the TestStand Engine (from objSeqContext.Engine).

We will look at ways to take care of this in a future release.

Michael Dozier (NI)
Message 5 of 7
(4,421 Views)
Thanks Michael, this has fixed the problem. I also communicated this to a person in our software division that I had been working on the problem with. He had the following to say (if it's any help)

---

If that's the workaround they suggest, It sounds like some of their cleanup code is defined in a class destructor. Destructors only get called when the garbage collector runs. Note their mistake: Never define vital cleanup code in a .NET class destructor… Use the Disposable pattern of defining the cleanup in the protected Dispose(bool) method and call the dispose method from the destructor.
0 Kudos
Message 6 of 7
(4,397 Views)


@Grefyne wrote:
Thanks Michael, this has fixed the problem. I also communicated this to a person in our software division that I had been working on the problem with. He had the following to say (if it's any help)

---

If that's the workaround they suggest, It sounds like some of their cleanup code is defined in a class destructor. Destructors only get called when the garbage collector runs. Note their mistake: Never define vital cleanup code in a .NET class destructor… Use the Disposable pattern of defining the cleanup in the protected Dispose(bool) method and call the dispose method from the destructor.




The problem is that the .net class is really just a runtime callable wrapper around a COM object and the reference to the COM object is not getting released by the .net wrapper class until the wrapper class object is destroyed. Another work around would be to hold onto the engine ref in a variable and call ReleaseComObject on it when you are done with it. We will look into a better way to handle this in the future.

Hope this helps explain things,
-Doug
Message 7 of 7
(4,382 Views)