NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to unload .net assembly?

My .net 3rd party assembly utilises a configuration file when calling in a step. If I update the configuration file, new settings are first read after closing TestStand and starting it again. In a deployed test station this is unconvinient.

 

I found this old document https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000PA5MSAW&l=en-US describing how to make a work around. I tried setting existing object reference to Nothing without success in my TS2016.

How can I unload .net assembly so that new configuration file is read on every execution?

 

0 Kudos
Message 1 of 7
(4,266 Views)

 

Looks like I referenced to incorrect document. It should be

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019LbySAE&l=en-US

 

0 Kudos
Message 2 of 7
(4,248 Views)

Hi Petri,

 

Have you tried you setting the Sequence File's Unload Option to "Unload after sequence executes"? See table 2 in the following document:

https://www.ni.com/en/support/documentation/supplemental/08/improving-teststand-system-performance.h...

 

If this doesn't work, you could consider opening and closing TestStand programatically, e.g. make a batch file which calls your sequence with the /quit modifier and then reloads the sequence in the next line. The following link might help

https://www.ni.com/docs/en-US/bundle/teststand/page/configuring-sequence-editor-and-user-interfac.ht...

 

Let me know if this is useful.

 

Best regards,

 

Leah

0 Kudos
Message 3 of 7
(4,223 Views)

Hi Leah,

thanks for response. I have tested different unload options available on the step settings. They don't seem to have any difference. I need to close TestStand and start it again.

 

Regarding the second hint you have closes the user interface automatically after execution of the sequence file if I understand it correctly. I want to avoid it, because we have customised report generation giving extra information at the end of the sequence model on the user interface. I prefer to that operator will see that information.

 

0 Kudos
Message 4 of 7
(4,217 Views)

It appears that my link was broken, sorry about that! I was trying to link to https://www.ni.com/docs/en-US/bundle/teststand/page/configuring-sequence-editor-and-user-interfac.ht...

 

To expand upon my idea, I was thinking that you could make another sequence for your operator to run, who's only step would be to run a batch file (a string of command prompt lines).  The instructions in the batch file would be:

 

  • Run your existing sequence with the 'quit' command line argument such as SeqEdit.exe /run MainSequence "c:\My Seqs\test.seq" /quit. This will close down the sequence and the TestStand engine safely.
  • Open the report in a format that doesn't have to be viewed in TestStand, like xml, and bring this to the front
  • Reopen TestStand and the sequence in the background

 

This does seem needlessly complicated, so I'll see if I can come up with an alternative solution. Someone else might know a way of doing it without closing TestStand, which would be ideal!

 

 

 

 

0 Kudos
Message 5 of 7
(4,207 Views)

I believe the following statement in the Knowledge Base article you referenced is inaccurate:

 

TestStand cannot unload a .NET assembly from memory until TestStand unloads all steps that call into the .NET assembly and you release all objects created from the assembly

 

In fact, TestStand cannot unload any .NET assembly until you release all objects created in all loaded .NET assemblies. So even if you release all references to the objects in your assembly there may be other live references to objects in other .NET assemblies that are preventing your assembly from unloading. 

 

One thing you can try is to programmatically unload all assemblies by calling the Engine.UnloadAllModules method. Of course this method unloads all modules, not just .NET modules, and calling this method will require that all steps reload their modules before they execute again.

Message 6 of 7
(4,203 Views)

Thanks for guiding on this.

 

I tried also Engine.UnloadAllModules with object reference to RunState.Engine and object class set to Engine (IEngine), but without success. My adapter was ActiveX/COM. I'm not sure if that was the correct object reference to call this method. At least I didn't get any errors.

 

Do I understand correctly if the 3rd party .NET assembly supports discard all references to its configuration files and TestStand had only this assembly loaded, could TestStand do things right then as I would like it to do in my initial question?

0 Kudos
Message 7 of 7
(4,137 Views)