Error 1172: A .NET Exception Occurred in LabVIEW™

Updated Sep 29, 2022

Reported In

Software

  • LabVIEW

Issue Details

  • How does LabVIEW handle .NET exceptions?
  • I am trying to call a .NET assembly in LabVIEW and I'm getting the following error:
Error 1172 occurred at an unidentified location.

Possible reason(s):

LabVIEW: A .NET exception occurred in an external assembly. For information about correcting this error, copy the following exception (in bold) and search the Microsoft Developer Network (MSDN) Web site or the Web for a possible explanation.

 
  • When I try to access a property from a .NET Property Node, I see Error 1172 (shown below). How can I resolve this?

Solution

Any exception thrown when calling a .NET object property or method is converted into LabVIEW error 1172. This error means that LabVIEW received a .NET exception from the called API. The root cause of the error will be related to the .NET exception message, as 1172 is a generic error code for any .NET exception.

This article will detail the necessary steps to:
  1. Obtain the full .NET exception message.
  2. Troubleshoot the error in order to resolve it.
 

Obtaining the .NET Exception Message

In LabVIEW 8.0 and Later

In LabVIEW 8.0 and later, more information was added to the error messages by placing the .NET exception message property into the Source string of the Error Cluster.

This exception message can only be accessed when implementing manual error handling. Within the error handling, the Source element of the Error Cluster can be unbundled to reveal additional error information. For more information about error handling, refer to Handling Errors in LabVIEW.
 

In LabVIEW 7.x

In LabVIEW 7.x, additional .NET exception information cannot be obtained. Move to the next section to troubleshoot the error.
 

Troubleshooting the .NET Error

  1. Ensure that the .NET assemblies are saved in the correct directory.
    • For standalone VIs (not within a project), the assembly must be saved in the directory that contains the LabVIEW.exe. This is usually C:\Program Files (x86)\National Instruments\LabVIEW 20xx where xx stands for the version number.
    • For VIs within a project, save the assembly in the project directory or any of it's subdirectories.
    • For build applications, Application Builder automatically saves the assemblies in the data subdirectory. This must be distributed along with the application.
    • Shared assembles (including assemblies on a network drive) must be installed in the Global Assembly Cache (GAC). Refer to How to: Install an assembly into the global assembly cache for further details.
  2. For LabVIEW 7.x, add the .NET assembly as a reference in LabVIEW by selectin Tools >> Advanced >> NET Assembly References. Click the Add button and navigate to the location of the assemblies that are called.
  3. If distributing a built application, ensure that the target PC has the .NET Framework installed that corresponds with the .NET assembly.
  4. Use the Probe Tool to make sure the .NET object reference, originally created by the .NET Constructor Node VI , is valid.
  5. If using a 3rd party DLL, the DLL can be the cause of issue, which is highlighted in LabVIEW via this generic error.
    • Attempt to call the .NET DLL through another language to verify whether this function can be called. This can include calling it in another .NET assembly with a different access scope.
    • In this case, reach out to the 3rd party developer for further troubleshooting.
  6. Ensure that the .NET feature is supported in LabVIEW.