I'm writing a LabVIEW DLL to inspect LabVIEW project files, and I've noticed that if a project has a .lvlib reference in its Dependencies, then the Run-Time Engine contradicts itself about whether or not it can find the project file:
- Project.Open returns error 7 (file not found)
- Project.GetFileLVVersion is successful
Here are snippets from my G and C code that exercise this behavior:
![OpenProjectSnippet.png OpenProjectSnippet.png]()
int openStatus = StatusSuccess;
char* projectVersion = createStringWithLength(VersionStringLength);
printf("Analyzing %s\n", pathString);
OpenProject(pathString, &openStatus, projectVersion, VersionStringLength);
printf(" Project written in LabVIEW %s\n", projectVersion);
if (openStatus == StatusSuccess)
{
printf(" Opened project file.\n");
}
else
{
printf("Error: Could not find project file, or file was not a project file (error code %i).\n", openStatus);
}
However, when running in the development environment, both methods succeed.
Is this a bug, and if so, is it fixed in LabVIEW 2014?
Here is how you can reproduce it:
Prerequisites:
- LabVIEW 2013 SP1 32-bit
- ConEmu for a good console -- https://code.google.com/p/conemu-maximus5/wiki/Downloads
- minGW for compiling a program to use the LabVIEW DLL -- http://sourceforge.net/projects/mingw/files
.lvlib reference in Dependencies breaks Project.Open in LV RTE
- Unzip the attachment into a temporary directory (eg c:\xtra\temp)
- Open "OpenProject.lvproj" in LabVIEW.
- Build "Open Project Library".
- Using ConEmu with a bash prompt, navigate to the temporary directory.
- Type make
$ make
patching file `builds/platdefines.h'
gcc -std=c99 -g OpenProject.c -o OpenProject.exe -lOpenProject -Lbuilds
6. Type OpenProject 'c:\xtra\temp\OpenProject.lvproj'
$ OpenProject 'c:\xtra\temp\OpenProject.lvproj'
Analyzing c:\xtra\temp\OpenProject.lvproj
Project written in LabVIEW 13.0
Opened project file.
7. Notice that both invoke nodes execute correctly.
8. Type OpenProject 'c:\xtra\temp\OpenProjectWithLvlibDep.lvproj'
$ OpenProject 'c:\xtra\temp\OpenProjectWithLvlibDep.lvproj'
Analyzing c:\xtra\temp\OpenProjectWithLvlibDep.lvproj
Project written in LabVIEW 13.0
Error: Could not find project file, or file was not a project file (error code 7).
9. Notice that the version node succeeded while the open one failed.
10. Type diff OpenProject.lvproj OpenProjectWithLvlibDep.lvproj
$ diff -u OpenProject.lvproj OpenProjectWithLvlibDep.lvproj
--- OpenProject.lvproj Tue Nov 4 11:28:28 2014
+++ OpenProjectWithLvlibDep.lvproj Tue Nov 4 11:32:37 2014
@@ -13,7 +13,11 @@<Property Name="server.vi.propertiesEnabled" Type="Bool">true</Property><Property Name="specify.custom.address" Type="Bool">false</Property><Item Name="OpenProject.vi" Type="VI" URL="../OpenProject.vi"/>
- <Item Name="Dependencies" Type="Dependencies"/>
+ <Item Name="Dependencies" Type="Dependencies">
+ <Item Name="vi.lib" Type="Folder">
+ <Item Name="NI_MABase.lvlib" Type="Library" URL="/<vilib>/measure/NI_MABase.lvlib"/>
+ </Item>
+ </Item><Item Name="Build Specifications" Type="Build"><Item Name="Open Project Library" Type="DLL"><Property Name="App_copyErrors" Type="Bool">true</Property>
Here is another way to trigger this behavior, which also shows that LabVIEW only sometimes tidies the Dependencies item:
- Open "OpenProject.lvproj" in LabVIEW.
- Add a new VI to the project and place the "Application Directory" file path constant its block diagram.
- Select "File » Save All (this Project)" and use the default name for the new VI.
- Type OpenProject 'c:\xtra\temp\OpenProject.lvproj'
- Notice there is an error again, as is expected.
- Remove the "Application Directory" file path constant.
- Select "File » Save All (this Project)"
- Type OpenProject 'c:\xtra\temp\OpenProject.lvproj'
- Notice the problem is gone, as is expected.
- Re-add the "Application Directory" file path constant to the block diagram.
- Select "File » Save All (this Project)"
- Type OpenProject 'c:\xtra\temp\OpenProject.lvproj'
- Notice there is no problem, which is surprising as there should be an error since the Dependencies item hasn't been tidied.
- Close the new VI and remove it from the project.
- Select "File » Save All (this Project)"
- Open "OpenProject.lvproj" in a text editor.
- Notice the Dependencies item has been tidied.
- Re-add the VI back to the project.
- Select "File » Save All (this Project)"
- Type OpenProject 'c:\xtra\temp\OpenProject.lvproj'
- Notice there is an error again, as is expected.