NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Sequencefileload freezes when calling DLL

Solved!
Go to solution

Hi,

I have TestStand 4.1 and when calling a DLL on the MainSequence everything seems to work fine, but if I call it on a SequenceFileLoad TestStand freezes on that step.

What could be the problem?

 

Regards,

 

Daniel Coelho

 

Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 1 of 11
(4,815 Views)

Hi Daniel,

 

What are you doing in the dll?

 

Can debug the DLL and find out where in the dll is causing the hang.

 

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 2 of 11
(4,805 Views)

Hi Ray,

thank you for your reply.

 

The DLL does 3 actions at this point:

 - reads an ini file;

 - reads two xml files and stores the data on a dynamic array of strucutres;

 - writes every action taken to a txt file.

 

If I put a Wait ( 1 ) before the step on the SequenceFileLoad it works fine.

It's odd.

 

I hope I can find out why this happens.

Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 3 of 11
(4,802 Views)

Hi Daniel,

 

where is this dynamic array of structures?

 

regards

Ray

Regards
Ray Farmer
0 Kudos
Message 4 of 11
(4,794 Views)
The DLL reads the data and saves it in memory as an array. When I unload the DLL the array is freed.
Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 5 of 11
(4,791 Views)

Daniel,

 

What did you build your DLL with?  Have you attached a debugger  to the TestStand process or steped into the code and tried to catch any errors that are thrown?

Message Edited by Josh W. on 03-16-2009 04:56 PM
Josh W.
Certified TestStand Architect
Formerly blue
0 Kudos
Message 6 of 11
(4,766 Views)

Daniel,

 

Is it possible to post an example highlighting the problem?

 

Regards

Ray

Regards
Ray Farmer
0 Kudos
Message 7 of 11
(4,754 Views)

Hi, I steped into the CVI code and managed to find some code that "could" be causing dynamic errors on the DLL.

Now the step doesn't freeze, but still it's a bit confusing why the step that calls the DLL only freezes on the SequenceFileLoad and not on the MainSequence.

How can I debug (CVI) DLL calls on TestStand?

Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 8 of 11
(4,664 Views)

Hi.

I'm back with the same issue.

I steped inside the DLL and rebuilt it with LabWindows CVI 8.5 but this time I commented all the code, i.e., its like the DLL does nothing when loaded.

This way the DLL is loaded fine by TestStand 4.1 with the SequenceFileLoad Sequence.

But if I put a printf() on the DLLMain DLL_PROCESS_ATTACH, TestStand freezes saying  "[Running...]" and I dont even see the printf() output.

 

What I'm trying to say is that a printf couldn't be the cause of the problem.

 

Can you help me some more?

 

Regards.

Daniel Coelho
VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
Controlar - Electronica Industrial e Sistemas, Lda
0 Kudos
Message 9 of 11
(4,572 Views)
Solution
Accepted by Daniel Coelho

Daniel,

 

Actually, printf() may be the problem.  Because you are calling it in DLLMain, there are additional considerations you have to keep in mind.  Microsoft has a great page on these considerations here:  http://msdn.microsoft.com/en-us/library/ms682583(VS.85).aspx

 

A few excerpts:

The entry-point function should perform only simple initialization or termination tasks. It must not call the LoadLibrary or LoadLibraryEx function (or a function that calls these functions), because this may create dependency loops in the DLL load order. 

 

Calling functions that require DLLs other than Kernel32.dll may result in problems that are difficult to diagnose. For example, calling User, Shell, and COM functions can cause access violation errors, because some functions load other system components. Conversely, calling functions such as these during termination can cause access violation errors because the corresponding component may already have been unloaded or uninitialized.

I'm pretty sure that printf() is a shell command.  Also, while loading the sequence file, it is likely that TestStand is loading DLLs or COM objects at the same time, which could confict with any code you have in DLLMain.

 

Regardless, Microsoft strongly recommends against any unecessary code in DLLMain.  So this problem may not have anything to do with NI products, but more DLL creation best practices in general.

Josh W.
Certified TestStand Architect
Formerly blue
Message 10 of 11
(4,569 Views)