Jump to content

DLL is not accessible after restart


TobyD

Recommended Posts

I've been struggling with a problem. Hopefully I can explain it accurately. :headbang:

I have a .dll that I am making function calls to to communicate with a USB instrument (all call library function nodes are wrapped in individual sub VIs). The only way I can get LabVIEW to "see" the instrument on USB is to close my program, move the dll out of the expected location, load the program (LabVIEW can't find the dll), and then move the dll back to its original location and browse to it. I am then able to access the instrument without problems until I close LabVIEW (I can close and reopen my program and it still works). When I reopen my program I have to go through the "hide the dll" game to get it to work again. Any idea what I might be doing wrong? Do I have to add the dll path to my system path variable?

-Toby

Link to comment

QUOTE(TobyD @ Nov 28 2007, 02:59 PM)

I've been struggling with a problem. Hopefully I can explain it accurately. :headbang:

I have a .dll that I am making function calls to to communicate with a USB instrument (all call library function nodes are wrapped in individual sub VIs). The only way I can get LabVIEW to "see" the instrument on USB is to close my program, move the dll out of the expected location, load the program (LabVIEW can't find the dll), and then move the dll back to its original location and browse to it. I am then able to access the instrument without problems until I close LabVIEW (I can close and reopen my program and it still works). When I reopen my program I have to go through the "hide the dll" game to get it to work again. Any idea what I might be doing wrong? Do I have to add the dll path to my system path variable?

-Toby

Could it be that your DLL calls indirectly other DLLs that are in the same directory? When LabVIEW asks Windows to load a library at a specific path Windows does attempt to load it, and when that library references other libraries it tries to load them too. If one of those referenced library loads fails the entire load fails and Windows tells LabVIEW: sorry!

Now Windows will search for libraries in following order:

1) a library with the same name is already mapped in the process space

2) inside the directory where the executable for the current process is located (here the directory where LabVIEW.exe is)

3) in the System directory

4) in the Windows directory

5) in any directory mentioned in the current PATH environment variable

and most possibly also in the "current directory".

The current directory is a process specific global variable that gets manipulated by various Windows APIs. One of them is also the API that LabVIEW uses to display the System File Dialog.

So if you browse to your DLL directory to tell LabVIEW which DLL to load and that DLL references other DLLs implicitedly that are in the same directory, Windows suddenly will find them, but not before.

Solution would be either to move those DLLs all into a location that is properly searched by Windows, or add the location of that directory to the PATH environment variable.

Rolf Kalbermatter

Link to comment

QUOTE(rolfk @ Nov 29 2007, 02:15 AM)

Could it be that your DLL calls indirectly other DLLs that are in the same directory?

That sounds like what is happening. I know the dll in question does call three other dlls that I have in the same directory. I'm not at work today so I can't test this out, but I'll update this post when I know something. Thanks :D !

Link to comment

QUOTE(TobyD @ Nov 29 2007, 09:33 AM)

I'll update this post when I know something.

I don't see an option to edit my last post - I guess there must be a time limit on that feature? Anyway...That did the trick. I added the directory to my system path variable (had to reboot for changes to take effect) and now it works as expected. Yay! :worship:

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.