|| 1.10 out of 5
.NET Assembly Called from LabVIEW Cannot be found
LabVIEW Development Systems>>LabVIEW Base Development System
Primary Software Version:
Primary Software Fixed Version:
LabVIEW Development Systems>>LabVIEW Full Development System, LabVIEW Development Systems>>LabVIEW Professional Development System
I am trying to call a .NET assembly from LabVIEW that references a separated file, such as a configuration file. The LabVIEW VI, .NET assembly, and configuration file are all stored in the same directory. The .NET assembly is supposed to look in its own directory for this configuration file, but when I run VI, the .NET assembly throws an exception. The error says that the configuration file could not be found in some subdirectory of
C:\...\Local Settings\Application Data\assembly\dll2
. I checked that directory and my .NET assembly did get copied there. Why is this happening, and what can I do about it?
When LabVIEW calls a .NET assembly, it enables a .NET feature called Shadow Copying. With this feature enabled, the .NET Framework automatically copies the DLL to a temporary directory under
\Local Settings\Application Data\assembly\dll2
before locking the resource and executing it from that location. Shadow Copying is designed to allow concurrent development on a .NET assembly while a copy of it is running. It is also standardly used in the ASP.NET development environment. To disable this feature in LabVIEW 2011 or later, add the INI flag AppDomainSetup_ShadowCopyFiles=False
to the LabVIEW.ini
file located in the labview
directory. For previous versions of LabVIEW, you cannot turn off this feature, but you can account for the shadow copy in your .NET assembly code so that you can referencethe dependency file in its correct location.
There are two ways to reference the location of a .NET assembly on disk, using the
Location property and the
CodeBase property for an assembly. Both are properties of the
System.Reflection namespace. The
Location property references the location on disk where the exact copy of the DLL that is currently being executed is located. This property returns the location of the shadow copy for a DLL. You can use the
CodeBase property for the assembly to get its location on disk before it was copied. This will give you the original directory that contains the configuration file for the assembly.
Refer to the links below for more information on the
Location properties and calling .NET assemblies in LabVIEW.
In LabVIEW 2011, you can use the .NET Assemblies in Memory dialog box to verify the location from which LabVIEW loaded an assembly.
Related Links: LabVIEW 2011 Help: Using .NET with LabVIEW LabVIEW 2011 Help: .NET Assemblies in Memory Dialog BoxMSDN Library: Assembly.CodeBase Property MSDN Library: Assembly.Location Property