01-22-2021 05:43 PM
I am working on a C# program running in a .NET module in TestStand, so I have Visual Studio and TestStand open. I change/compile my code in Visual Studio and then I try to run my sequence, which calls a method in my C# program.
I have the very annoying problem of needing to do File > Unload All Modules, after every time I run my sequence, or else I can't recompile my C# code. I get this error in Visual Studio:
Unable to copy file "obj\Debug\WindowsFormsApp1.exe" to "bin\Debug\WindowsFormsApp1.exe". The process cannot access the file 'bin\Debug\WindowsFormsApp1.exe' because it is being used by another process.
How do I unload my .exe (from the .NET modules) at the end of my sequence? I try calling RunState.Engine.UnloadAllModules() in a Statement in my sequence, but it doesn't work.
I have attached a dead simple example with a .seq file and a C# file.
My problem is compounded by a project I'm working on that has a separate sequence running constantly in the background, in addition to my custom sequence. So when I do File > Unload All Modules, I have to rerun that separate sequence before I can run my custom sequence.
Solved! Go to Solution.
01-24-2021
04:58 PM
- last edited on
04-04-2025
01:51 PM
by
Content Cleaner
Have you seen this: https://www.ni.com/en/support/documentation/supplemental/19/unloading--net-assemblies-in-teststand.h...?
02-01-2021 04:07 PM
That link did help. The last paragraph mentioned that the Sequence Analyzer can prevent .NET modules from being unloaded.
I went to Debug > Sequence Analyzer > Sequence Analyzer Options... -- and in the dialog, I unchecked "Analyze File Before Executing". After that, I stopped needing to click Unload All Modules.