From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView .Net Interop and Arrays

I'm creating a solution that calls some LabView code from C# application.   I've created a .Net interop assembly for the LabView code that I want to call from my C# application.   VI's that have parameters of simple datatypes like int, string, double, etc are callable - no problem.   Vi's that use arrays of simple data types like array of doubles, are not callable.

 

 

The Labview IDE shows the footprint for function being generated as:   

 

void GetUserTags(out Array Array).  

 

When I view that function in the built dll in the Visual Studio Class browser I see this:  

 

public static void GetUserTags(out  array)

 

Note there is no type on the parameter and hence why I believe its not callable from my C# environment.     Anyone got any idea's what happening here?   Are array's valid parameters for .Net interop?  Am I'm going to have to use an Active X library instead? 

 

Note that this is Labview 2014/Visual Studio 2015 if that matters. 

 

 

 

0 Kudos
Message 1 of 17
(5,999 Views)

Upgrade to LabView 2015.  Still the same problem.   

 

Cluster get class definations made, but any fields that are arrays get dropped. 

0 Kudos
Message 2 of 17
(5,945 Views)

Well, apparently I'm not the only one having this issue:

 

.Net Interop method is not supported by the language

 

0 Kudos
Message 3 of 17
(5,926 Views)

Hello Edwwsw

 

It seems that this is not a LabVIEW issue if you are creating the Interop in the correct way. "When you build a .NET interop assembly, LabVIEW directly translates simple data types such as numerics, booleans, strings, and arrays of simple data types to the corresponding", so you not have a problem to works with arrays in .NET interops

 

Also you can check more information about .NET interop on the next link

http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/building_a_net_assembly/

 

Regards 

Miraquesa

0 Kudos
Message 4 of 17
(5,899 Views)

Have you gotten this to work specifically with Visual Studio 15?  Because just like the other post I tracked down,  this problem seems to be showing up in Visual Studio 15.   

0 Kudos
Message 5 of 17
(5,893 Views)

Narrowing it down further.

 

Arrays of doubles and strings have problems.   Arrays of floats seem to pass through.  This problem is only showing up in Visual Studio 2015. 

0 Kudos
Message 6 of 17
(5,840 Views)

Hello Edwwsw,

 

I have on my computer Visual 2010, maybe you wanna try with another version on VS. 

 

let me know the results 

 

Regards,

 

Miraquesa

0 Kudos
Message 7 of 17
(5,803 Views)

Looks like MS is working on a solution to the problem.

 

 

This issues:

 

https://connect.microsoft.com/VisualStudio/feedback/details/1668248/net-interop-method-is-not-suppor...

 

has been updated to like to this bug:

 

https://github.com/dotnet/roslyn/issues/4924

 

Message 8 of 17
(5,700 Views)

Same problem here.

 

It seems VS2015 doesnt recognize the arrays beign declared in a Labview .Net Interop DLL.

 

Here is my function, as you can see there is no defined type

public static bool Init(string filename_Config, out stringArray, out dataArray)
Member of XWaveDv.XWaveDriver

 

and in the code calling.

InitArray.PNG

 

Clusters are declared as new typedef and works quite well. But an Array inside a cluster is also not recognized. All the problems are the arrays.

 

Is there a workaround?? I really need to send a couple of arrays from a labview DLL to C#.

0 Kudos
Message 9 of 17
(5,541 Views)

This is a known MS bug.  They know about the issue (https://connect.microsoft.com/VisualStudio/feedback/details/1668248/net-interop-method-is-not-suppor... and probably have a fix for it (https://github.com/dotnet/roslyn/issues/4924).  It just hasn't been release yet. 

 

The problem is that Labview generates IL code for single dimension arrays as if the array were a multidimensional array of rank 1.  That is labview treats a[10]  as if it were a[1][10] from an .Net low level instructional language (IL)  standpoint.   This causes visual studio 15 issues.   

 

I've worked around the issue (for now) by just passing two dimensional arrays out of labview.    Instead of returning a[10],  I return a[2][10].   This is a ugly hack to get around the issue.

 

NI could also address the issue by generating IL code for a[10] as if it were a single dimensional array. 

Message 10 of 17
(5,496 Views)