05-02-2021 09:58 AM
I know this is an old topic but I ran across it while trying to figure out how to use dotNET to set inheritable permissions on directories in Windows and, as near as I can tell, this question of how to create the dotNET constant with the correct datatype for use with the "To More Specific Class function" was never answered. Just to wrap things up for this discussion, I'd like to suggest that the following discussion would seen to hold the answer:
11-07-2022 07:46 PM
I have tried all of the methods on here and none of them work for me. I get Error 1172 which I believe is telling my that I am passing a NULL type to the Activate Invoke node -
Is the string typeName that I have listed invalid?
11-08-2022 01:46 AM
Hi,
have you seen message 15 (https://forums.ni.com/t5/LabVIEW/How-do-I-create-a-NET-List/m-p/3089679#M883437 ) in this thread?
There should be no space in between: System.Collections.Generic.List`1[System.String]
From your picture it seems there is a space in the string.
11-08-2022 09:21 AM
There is indeed a space in the string, as you say. I get the same with and without the spaces, both in the type name and also within the parameters in the square brackets. I have also have the same problem when I include just [System.String] instead of the full list of parameters in the square brackets. I think I have tried all combinations for the string format and nothing solves my problem. Still seems like the type name cannot be found. Any other ideas? I am using LV 2017 SP1, BTW.
11-08-2022 11:21 AM
Seems that System.Activator needs the type from an active instance? This seems to work....
11-09-2022 10:10 AM
Thanks for all of the suggestions, everyone, but none of them have worked. I still am not able to create a list based on the the string typeName I am using. My problem is that I need to create a list (type List<String> and then pack a reference to that list to a .NET method. Are there other string type names I should be trying?
I am trying to use the downcast reference to build a list. Again the System.Type appears to be returning a NULL on the Get Type terminal.
11-09-2022 12:43 PM
Assuming that the .NET reference constant you have there is a null instance of the actual Generic list you need to create, there is a way to extract the .NET type string programmatically in LabVIEW using the Variant to Flattened String function:
You could try that just in case there's something different about the type name you need to use on your system compared to the constant string you made.
11-10-2022 02:16 AM
One thing that's important to note is the apostrophe after the type is not the standard one (0x27) but one with the ASCII value 0x60. I'm guessing this is your issue.
Another point is that you can get the assembly info for the internal type using .NET, which should make it somewhat safer. See this example for a dictionary, which has two internal values, but it should be the same for a list:
11-10-2022 08:44 AM
Yes! I was wondering about the apostrophe! I recreated the string using the Ox60 character (alt +96) in place of the regular apostrophe, and the type is now valid and I can now create an instance. Note it also required NO SPACE between the 0x60 character and the "1". Thank you very much Good Sir Knight!
11-10-2022 09:09 AM
To be more specific, it's not actually an apostrophe, but a "grave accent". For a bit more detail, you can see the note in the following link. In general, information about this seems scarce.
Note
For generic interfaces, the
name
parameter is the mangled name, ending with a grave accent (`) and the number of type parameters. This is true for both generic interface definitions and constructed generic interfaces. For example, to findIExample<T>
(IExample(Of T)
in Visual Basic) orIExample<string>
(IExample(Of String)
in Visual Basic), search for"IExample
1"`.