Loading .NET 2.0, 3.0 and 3.5 Assemblies in LabVIEW

Updated Aug 24, 2023

Reported In

Software

  • LabVIEW Full

Issue Details

I created a .NET assembly using the .NET Framework 2.0, 3.0 or 3.5, but when I try to load the assembly in a Constructor Node, I get the message: The selected file is not a .NET assembly, type library, or automation executable.  Is it possible to load a .NET 2.0, 3.0 or 3.5 assembly in LabVIEW?

Solution

Place a configuration file next to LabVIEW.exe, it must be named LabVIEW.exe.config.  The following example instructs LabVIEW to load .NET mixed-mode assemblies that target the CLR 2.0:
 
<?xml version ="1.0" encoding="utf-8" ?>
<configuration>
   <startup useLegacyV2RuntimeActivationPolicy="true">
      <supportedRuntime version="v4.0.30319"/>
   </startup>
</configuration> 

 

Additional Information

LabVIEW employs a set of default behaviors to determine which version of a particular .NET assembly to reference and which version of the Common Language Runtime (CLR) to load. For example, LabVIEW 2017 uses the .NET CLR 4.0 by default which allows it to use up to the .NET Framework 4.6.2, while LabVIEW 2012 uses the CLR 2.0 by default which only allows it to use up to the .NET 3.5 framework.  You can create a .NET configuration file to override the default ways that LabVIEW loads the CLR. 

You can force LabVIEW to load .NET assemblies that are targeted to the CLR 2.0. However, assemblies that target older versions of the CLR might behave unexpectedly. 

If creating an executable application with the .NET 2.0 framework, ensure that there is also a configuration file in the same folder as that executable.  This would be the exact same configuration file that was placed next to LabVIEW.exe, however, it must be renamed to Executable Name.exe.config

Note: The supportedRuntime version token must match the version of the .NET Framework that is installed. You can verify this by checking in Add/Remove Programs for the .NET 2.0 version you have installed. You can find an overview here: (external link) <supportedRuntime> element