Switching Between Different Versions of .NET Assemblies in LabVIEW

Updated Sep 20, 2023

Reported In

Software

  • LabVIEW

Programming Language

  • Visual Basic .NET

Issue Details

I have a LabVIEW program that can use two different assemblies. I want to be able to select which assembly to load. Both assemblies have the exact same name, but have different version numbers. How can I choose which assembly LabVIEW will load?

Solution

Option 1 Only have one assembly loaded into the GAC (Global Assembly Cache) at a time
Due to the dynamic characteristics of LabVIEW, the application will only discover and load the assembly that is present in the GAC. 

Note: If the new assembly contains additional methods and properties, you will still need to use the configuration file listed below in options 2 or 3 in order for the LabVIEW Constructor Node to be properly updated with the additional methods and properties.

Option 2 Both assemblies are present in the GAC
You can use a .NET configuration file to select which version of the assembly that your LabVIEW project/shared library/stand alone application (executable) should use. For instance, if the name of the LabVIEW project is Test.lvproj, then the name of the config file should be named Test.lvproj.config. The configuration file should be located in the same folder as the LabVIEW project you are trying to change. For more information check Configuring a .NET Client Application. An example configuration file is listed below.
Note: It is possible to redirect from one of multiple old versions to the new version. This can be accomplished by specifying the argument of oldVersion within the bindingRedirect tag, as a range of versions rather than a single version number. For example n.n.n.n - n.n.n.n.

Option 3 Both assemblies do not need to be present in the GAC
You can still use a .NET configuration file to select which version of the assembly that your LabVIEW project/shared library/stand alone application (executable) should use. For more information, refer to Configuring a .NET Client Application.

If you are browsing to a particular folder to select the assembly, then use the following configuration. The only difference here is that the path of the assembly is mentioned <probing privatePath="Assembly\ver2"/>, where Assembly\ver2 is a subfolder within project. This path has to be relative to where the configuration file is present. It forces the VI to first search in the particular folder before others and hence selects the right version.
 
Configuration file considerations:
  • The configuration files works with LabVIEW 8.5, and later.
  • assemblyIdentity name="Test" - Test represents the name of the assembly, and must match identically to the name of the assembly in order to function correctly.
  • publicKeyToken="xee7d93a67000dr7" - Is used to uniquely identify an assembly. It is generated using the SN tool.
  • oldVersion=" " newVersion=" " - Represents the version you are currently using and which version you would like to use.
Steps to using the configuration file correctly:
  1. Check to ensure the LabVIEW code works correctly with one version of the assembly. Close the LabVIEW project and LabVIEW.
  2. Open the configuration file, and edit the code to change from the current version to the version you would like to use.
  3. Reopen LabVIEW and the project. Then run LabVIEW code. The LabVIEW code will now be using the version of the assembly that you specify.

Additional Information

Tip: Beginning with LabVIEW 2011, you can use the .NET Assemblies in Memory dialog box to verify that LabVIEW loads the correct version of an assembly.