12-21-2016 08:50 AM - last edited on 07-13-2024 04:46 PM by Content Cleaner
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?
12-21-2016 10:05 AM - last edited on 07-13-2024 04:47 PM by Content Cleaner
Looks like I referenced to incorrect document. It should be
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019LbySAE&l=en-US
12-22-2016 04:51 AM - last edited on 07-13-2024 04:48 PM by Content Cleaner
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:
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
Let me know if this is useful.
Best regards,
Leah
12-22-2016 05:45 AM
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.
12-22-2016 09:36 AM - last edited on 07-13-2024 04:48 PM by Content Cleaner
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:
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!
12-22-2016 10:05 AM
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.
01-04-2017 02:12 AM
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?