04-11-2009 07:20 PM - edited 04-11-2009 07:23 PM
Does anyone know why I can't seem to find the System.Collections.Generic.List object in LabVIEW's "Select .NET Constructor" dialog?
I'm trying to create a .NET "List" in LabVIEW (Namespace: System.Collections.Generic, Assembly: mscorlib), similar to how it's done in the text-based code, below.
List<string> myList = new List<string>();
The problem is that I can't seem to find the Generic List object contstructor anywhere.
System.Collections.Generic object under the System assembly (I was only able to find System.Collections.Specialized). I looked inside the mscorlib assembly and found the System.Collections.Generic object, but the only constructor is for something else.
Thanks for your help.
-Jim
Solved! Go to Solution.
04-11-2009 08:17 PM - edited 04-11-2009 08:17 PM
Whew... I figured it out. It's possible to create these generic types using reflection (dynamic object creation).
09-16-2010 02:17 PM
I am curious if this works for lists of object types as well?
I am using a customer provided API, and unfortunately most of the functions return a generic rtnObject that needs to be converted into the function specific data type. The non list returns were straightforward to convert but the list ones are providing a challenge.
Will I be better off just writting my own companion c# dll to convert these custom data types into something labview can more easily recognize?
sample C#
public override GatewayReturn GetLatestReads( uint gateway_id ) Return Value GatewayReturn with rtnObject as List of TransmitterReadMessageItem
02-18-2011 05:09 AM
@Jim Kring wrote:
Whew... I figured it out. It's possible to create these generic types using reflection (dynamic object creation).
Message Edited by Jim Kring on 04-11-2009 06:17 PM
Jim,
I neither have the System.Type NOR the System.Activator classes / methods available with the .NET 2.0 framework.
I can see that these are static classes (no constructor), but when I search System (2.0.0.0), I don't see classes or methods for System.Type or System.Activator. I also don't see System.Type or System.Activator as assemblies. MS .NET help tells me that System.Collections.Generic IS a namespace I should be able to see, but I dont.
I CAN see System.Collections.Specialized, but NOT System.Collections.Generic.
If I need to "force" labview to recognize this method using reflection, that's fine, but I can't even find the System.Type or System.Activator calls.
Specifically, what did you select when you configured these .NET invoke nodes?
Also, the string "System.Collections.Generic.List`1[System.String]" seems to have both special nomenclature and formatting. From where did you get the information on how to format this string to invoke this method?
Just a little lost here.....
Thanks,
Wes
02-18-2011 09:31 AM
System.Type and System.Activator are definitely part of .NET 2.0. Both these classes are sealed classes, not static classes.
In order to select a static method that a class may expose you need to:
The same process holds for the static method for System.Activator.
09-29-2011 04:04 AM
Hi
I use system.Type and System.Activator for create List of point
but when run it . i see this error
can you help me ?
thanks
09-29-2011 07:42 AM
The error string tells you the problem: The CreateInstance method threw an error because it was passed a null value. That means the GetType method did not work. It would not work if you passed it an invalid type. Have you verified that's a valid type?
09-29-2011 08:45 AM
I think it is true
09-29-2011 08:54 AM - edited 09-29-2011 08:54 AM
That doesn't prove anything. The reason why you can do what you are doing on the right-hand side is that you are casting a reference to something else. Try something like this:
09-29-2011 09:13 AM
thanks for your help
I use " GMap.NET.WindowsForm.GMapPolygon ( [[GMap.NET.PointLatLng, GMap.NET.Core, Version=1.5.5.5, Culture=neutral, PublicKeyToken=b85b9027b614afef]] points , string ) "
I must put List of point , i understand that can do it by use ( system.collections.generic.list ) , apparently labview does not support Generic .