NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Error Code: -17004, Could not load DLL or library

Solved!
Go to solution

Hi All,

 

I am getting the following error message:

Error loading step 'x' of sequence 'MainSequence' in file 'y'.  Could not load DLL or external library C:\bin\driver.dll

Error Code: -17004, Could not load DLL or library.

Source 'TSAPI"

 

My main DLL is one written in C in LabWindows.  This DLL calls a second DLL that was written in Visual C++

I am using TestStand 2010 SP1 as well as CVI/LabWindows 2010.  I have WinXP Professioanl SP3.

This same sequence, DLL1, and DLL2 have worked together in previous versions of TestStand!!!!  All I did was upgrade to Developer Suite 2011.......??????

 

I have reviewed all the posts regarding this problem and have so far done the following:

1.  Verified Both DLL1 and DLL2 reside in the same directory

2.  Copied DLL2 into C:\Windows\system32

3.  Used Dependency Walker to verify that there are no other missing DLL's

4.  Unistalled Explorer 8 and installed Explorer 7 because of somthing I saw in depends and something I read while researching this problem.

5.  Verified the Search Directories in TestStand

 

I am wits end, as I cannot determine what the problem is and any suggestions would be welcome

0 Kudos
Message 1 of 9
(9,564 Views)

Did you try procmon from sysinternals? (http://technet.microsoft.com/en-us/sysinternals/bb896645)

This tool might describe why there's a problem loading the dll.

0 Kudos
Message 2 of 9
(9,561 Views)

Have you rebuilt your DLL with the latest CVI that you have installed?

Regards
Ray Farmer
0 Kudos
Message 3 of 9
(9,531 Views)
Solution
Accepted by topic author greggj_00

Do you have the correct version of the visual C runtime on this machine? If it's a debug build of the dll you will need a debug version of visual C++ runtime. If you don't have visual studio installed it's unlikely to be installed on your machine.

 

You can open the dll in visual studio and look at its manifest in the resources of the dll to see what version of sxs dlls it is linked against. You need to make sure those all exist on your machine. Generally depends should show an issue if this is the problem though.

 

Hope this helps,

-Doug

Message 4 of 9
(9,526 Views)

Thanks Doug, that was the ticket.  I installed Microsoft Visual C++ 2010 Redistributable Package (x86) and now everything works as designed.  I had been using listdll.exe, procmon, and could not nail this down.  I appreciate the insight.

 

Regards,

greggj

0 Kudos
Message 5 of 9
(9,519 Views)

OK Doug,  maybe I spoke to soon.   For some reason my sequence worked right after I installed the

Microsoft Visual C++ 2010 Redistributable Package (x86), but the next time I tried to run it and all subsequent times, I got the same exact failure I was observing previously.  We're on the right track, but....  Can you think what would cause this type of error?

 

Thanks,

greggj

0 Kudos
Message 6 of 9
(9,512 Views)

Have you tried rebooting since? Does it work the initial time after rebooting? I can't really think of anything that would cause this behavior short of Windows Update maybe modifying the runtime in the background in order to install a patch. If so, running Windows Update to make sure it's finished and then rebooting might help.

 

-Doug

0 Kudos
Message 7 of 9
(9,498 Views)

So I did come up with a solution to this problem, but I don't understand why it solves the issue.  Hopefully some of you can provide some insight.

 

So all my sequences were experiencing the problem described, and all sequences basically call the same dll's over and over.

 

I have a dll that I use as my "main" dll.  All my sequences use this dll and I continually add more functions as our company designes new products, etc.  This dll uses functions that are from my CommDll.  The CommDll was written in C++, and it is also used in several other dll's that my sequence call's as I use it for all serial/telnet requirements. 

 

So my test sequences for example calls the following dll's usually in this particular order ---

DbDriver - This dll handles all the database functioanality for our products, and calls libMysql.dll

PwrController.dll - this dll controls a pwrcontroller for all power on/power off, reboot, etc of our product.  This dll calls the CommDll.

CompanyDll - This is the "main" dll that hadles all the cli commands and other test functions that our product requires.  This also calls CommDll.

 

When the sequence calls are done in the order above, it does not work..  However, if I switch the sequence file to call the CompanyDll before the PwrController.dll everything works fine.  Is there an order of operations here????

 

I also found that when I compiled my PwrController.dll with CVI 2010, it gave me an error could not load PwrController.dll no matter what order the seqence calls were, leading me to believe that I am missing something when building this particular dll.  As soon as I copy the original, developed and compiled in 2006, everything works again.

 

Thanks,

greggj

 

 

 

0 Kudos
Message 8 of 9
(9,468 Views)

I have an idea.

 

Basically, the way TestStand loads dlls (it's really the way the OS does it, but the OS provides two different ways for doing so), it will find dependent dlls if they are in the same directory as the dll you are directly loading. Thus what I think is happening is that CommDll is in the same directory as CompanyDll, but not in the same directory as PwrController.dll. So if you load CompanyDll first, it will be able to load CommDll and then when you load PwrController.dll it will load successfully because CommDll is already loaded. But if you load PwrController.dll first, the OS can't find CommDll and since it's not already loaded it fails.

 

What I recommend is you put all 3 of these dlls in the same directory so you don't have to duplicate Commdll and risk the multiple versions getting out of sync.

 

Hope this helps,

-Doug

0 Kudos
Message 9 of 9
(9,464 Views)