Can’t Call my LabVIEW-Built Interop Assembly with Array Parameter in Visual Studio 2015

Updated Aug 24, 2023

Reported In

Software

  • LabVIEW 2017 Professional
  • LabVIEW 2017 Base
  • LabVIEW 2017 Full

Programming Language

  • C# .NET

Issue Details

I created a .NET Interop Assembly in LabVIEW. This assembly contains a function which takes a one-dimensional array of doubles as a parameter. I am able to call this function from Visual Studio 2013 and earlier as expected. Starting in Visual Studio 2015, this function is not found by IntelliSense.

When I attempt to make the call manually, the code does not compile and an error is thrown that the type is not supported by the language.  In Visual Studio 2017, the error thrown is that the Value of type 'Double()' cannot be converted to 'Double(*)'.  How can I use array parameters in my .NET Interop Assembly with Visual Studio 2015 and later?

Solution

This behavior has been resolved within LabVIEW 2017 SP1. 

For versions including and prior to LabVIEW 2017:

In order to use a one-dimensional array parameter with Visual Studio 2015 and later versions, the workaround is to replace the one-dimensional array with a two-dimensional array in LabVIEW and re-build the .NET Interop Assembly. Visual Studio 2015 recognizes the two-dimensional array and the .NET programmer can then choose to ignore the second dimension if only one dimension is necessary. 

Additional Information

For LabVIEW versions 2017 and prior:

When a .NET Interop Assembly is created in LabVIEW, a one-dimensional array is represented as a multi-dimensional array of rank 1. In Visual Studio 2013 and earlier, this data type was recognized as a one-dimensional array. However, with the introduction of Visual Studio 2015, this type is no longer supported.

 If you are migrating from Visual Studio 2013 to Visual Studio 2015 and you would like to avoid modifying your LabVIEW Assemblies, an alternative workaround is to wrap the LabVIEW function calls in Visual Studio 2013 and create a class library. You can then call into the class library in Visual Studio 2015 and later without seeing the error.