NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't unload .NET modules when debugging

Solved!
Go to solution

Is there any way to fully unload all modules after a sequence has executed? I am trying to debug a .NET module using Visual Studio 2008. I attach it to the sequence editor process and I am able to do all the stepping in and setting breakpoints that I want. However, if I need to change my .NET module and recompile it, I can't do that without completely exiting the sequence editor. This is a big pain because the sequence editor doesn't exactly shutdown or startup any too fast.

 

Am I missing something? This really makes development difficult.

0 Kudos
Message 1 of 7
(5,033 Views)

Skeptical,

 

Have you tried choosing File» Unload all Modules?  In the NI TestStand Customer Education course (both regional and online) we teach you that this is the way to have TestStand force an unload of any code module from memory for further editing, whether it was created in .NET, LabVIEW, etc.

Derrick S.
Product Manager
NI DIAdem
National Instruments
0 Kudos
Message 2 of 7
(5,015 Views)

Hi,

 

You can also unload all modules programatically for example by using an ActiveX call like I do in the sequence below.

( I put this in cleanup for long sequences )

 

You probably can call this from TestStand API using a .NET adapter, and the appropriate dll that enables you to mess around with TestStand API.

 

Hope this helps,

Maciej 


0 Kudos
Message 3 of 7
(5,012 Views)
Solution
Accepted by topic author Skeptical

Skeptical -

 

Before you do Unload All Modules, you wil also need to detach the Visual Studio debugger from the TestStand.

There is a catch here:

  • You can only detach the Visual Studio debugger from a process if, when you attached it, you configured it to debug only one type of code (e.g. only Managed or only Native)
  • By default, the Visual Studio debugger is configured to debug both Managed and Native code when it attaches to a TestStand process (because TestStand has both Managed and Native code)

 

To avoid this catch, when you attach the Visual Studio debugger to the TestStand process, configure it to debug only Managed code. In Visual Studio 2008:

  • When you do Tools>>Attach to Process, there is an "Attach to:" control button with a "Select..." button next to it
  • Click the "Select..." button
  • Choose the "Debug these code types" radio button
  • Select only the"Managed" checkbox
  • Click OK and Attach

Then, before you rebuild your .NET code module, in TestStand you Unload All Modules and in Visual Studio you Debug>>Detach All.

 

To make the attach process a little more convenient, you can probably create a Visual Studio macro to attach in this manner (so you don't have to go through the menu and dialog boxes each time) and create a command button to run that macro.

 

 

To elaborate on Maciej's repsonse, I'd also like to point out that with TestStand 4.0 and later, you can use API in expressions (RunState.Engine.UnloadAllModules()) to unload all modules (instead of using the ActiveX adapter). 

 

David Rohacek

National Instruments

Message Edited by drohacek on 08-27-2009 10:46 AM
0 Kudos
Message 4 of 7
(5,000 Views)

Thanks to David and Maciej for your input.

 

For the sake of completeness I want to point out as well that TestStand 4.2 supports native Visual Studio 2008 debugging, which makes this process a lot simpler.  I gather from your previous posts that you're using TestStand 4.1.1, so this may be a consideration for you.

Derrick S.
Product Manager
NI DIAdem
National Instruments
0 Kudos
Message 5 of 7
(4,995 Views)

Thank you all for your help. I think I have it working (cross my fingers).

 

The key for me seems to be doing the Unload All Modules in the sequence editor before detaching the process in Visual Studio.

 

For what it's worth, I don't see the Debug>>Detach All menu item in either VS2005 Pro or VS2008 Pro. I can do Debug>>Windows>>Processes and select the process to detach. I guess I'll have to call Microsoft on that.

 

Thanks again.

0 Kudos
Message 6 of 7
(4,977 Views)

Just regarding VS,

 

You will see the Detach All option only after you have attached your VS code to a given process.

It doesn't become visible until your debugger is attached to a running process.

 

I'm assuming you just opened a project clicked on Debug and could not find it there, but you were not actually debugging an attached process.

I have VS 2008 and it shows for me.

 

Cheers, 

Maciej 


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