LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LoadLibrary fails with error code 5 after cloning project files and cws to another directory.

Solved!
Go to solution

I have a project that communicates to an instrument over a USB UART.   The telemetry packets from the instrument are defined in DLL's which the main application loads using LoadLibrary with a relative path input.  The plugin DLL's are two directories below the application executable  All has been working fine for months untill I needed to clone the project (using Hg).  The cloned project will no longer load the DLL's.  The DLL's are not corrupted as I can hard code their paths in my original project to them and load them just fine.  The cloned project finds the files (using GetFirstFile), so I know that the path string is corect, but is unable to load the DLL's using LoadLibrary.  The returned error code is 5.  Has anybody seen similar behavior when trying to copy or clone a project?

 

Thanks for any help you can give!

0 Kudos
Message 1 of 5
(5,847 Views)
Solution
Accepted by Siexto

When moving or copying projects from one location to another I simply copy the entire folder+subfolders and never had problems: CVI warns that paths need to be fixed al corrects everything by itself. Nevertheless, error 5 should be "Access denied" so you could check properties and security of the cloned files in order to guarantee that your code can access them properly.

 

Alternatively, couldn't you place the DLLs in some of the standard search-paths? This will avoid problems in cases like yours.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 5
(5,826 Views)

Thanks for the suggestions.  Placing the DLL's in the standard search paths did not work, I still received the Error 5.  I also verified file and directory permissions and creating a .local file for my application so that LoadLibrary would know to look for the DLL's in the application directory.  None of this worked.  I did however, inadvertantly, try your first suggestion though.  We are using FogBugz/Hg for our source control.  I cloned the source directory to my local machine.  Running this code fails when it trys to load the plugin DLL's using LoadLibrary function.  I then copied the files in the cloned directory to a new dierectory so that I could start performing a manual merge of this code with my local changes.  I decided to try and run the copied code to see if there was any difference and it worked!  Not sure why but it did.  So at least for now I guess this thread is closed.  Thanks again for the help!   

0 Kudos
Message 3 of 5
(5,802 Views)

hi,

 

i need some help..

i have a project using dll's where standart search path (application directory) was used. now inorder to maintain a single copy of dll for various project using the same. i am planning to use loadlibrary concept. can you please share the procedure how to use this function.

 

1.) i belive i need not change the code in dll for the path.

 

2.) do i need to change the main soucre code?? how to set a path ??

phani srikanth
0 Kudos
Message 4 of 5
(5,572 Views)

Question Posted and answered in a difference thread:

 

http://forums.ni.com/t5/LabWindows-CVI/dll-search-path/m-p/2492582#M62966

 

This is also more of a Windows questions and setting the PATH variable. There is a KnowledgeBase Article that goes over this a little be, but essentially goes over what was posted in this thread:

 

http://digital.ni.com/public.nsf/allkb/862567530005F09C862565C50068363D

Kurt P
Automated Test Software R&D
0 Kudos
Message 5 of 5
(5,548 Views)