Managing FPGA Refnums in LabVIEW .NET DLLs

Updated Apr 2, 2025

Reported In

Software

  • LabVIEW FPGA Module
  • TestStand

Issue Details

I am trying to create a .NET DLL from LabVIEW FPGA code. The VIs (source code) work fine when called directly from TestStand, but when wrapped into a DLL and called using the generated APIs, TestStand either hangs or throws an exception in Visual Studio. This issue also occurs when calling the LabVIEW-generated DLL from the C# API, so it isn't necessarily TestStand-specific. 

Solution

TestStand and other external applications cannot handle FPGA Refnums when interfacing with LabVIEW .NET Interop DLLs. To resolve this issue, perform the type casting within the DLL itself. Follow these steps:

  1. Convert the FPGA Refnum to a U64 Numeric Value: Within the DLL, cast the FPGA Refnum to a U64 numeric value before passing it to TestStand or the C# API using the Type Cast function. This ensures compatibility with the external application's data handling.


  2. Pass the U64 Numeric Value to the External Application: Use the U64 numeric value in your TestStand sequences or C# API calls as needed.

  3. Convert Back to FPGA Refnum in LabVIEW: When the value is returned to LabVIEW, use the same Type Cast function to cast the U64 numeric value back to an FPGA Refnum to restore its original type and functionality.


By implementing these steps, you can ensure smooth communication between external applications and LabVIEW through the .NET Interop DLLs.