LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

When LabVIEW meets .NET - a (un)happy marriage (part 1) ?

Solved!
Go to solution

While trying to access .NET functionality from LabVIEW 2011, I ran into a (first) problem.

The .NET interface uses an abstract type as return value, which needs to be "downcasted" to a more concrete (but still abstract) type to fully access its (abstract) functionality.

Right-clicking the property node to "Downcast to Class" is not supported for .NET and as such requires the usage of a "To More Specific Class".

Unfortunately the latter has one fundamental disadvantage that one has to provide (a reference to an object of) the target class instead of specifying the target class (as done in C# as part of a casting operation). As such I cannot use this "To More Specific Class", unless I overlook something.

 

So, is there anyone out there who knows how to deal with this problem ?

Thanks a lot to anyone who read my question and an extra thank you to anyone who provides a relevant answer or comment Smiley Happy

0 Kudos
Message 1 of 9
(4,152 Views)
Solution
Accepted by topic author fransv1963

You can create a reference to any public .NET class by dropping a .NET property node on the block diagram, clicking "create constant" on the reference input, then right-clicking the reference and choosing Select .NET Class -> Browse...  You can then connect this reference to the Type input of To More Specific Class.

0 Kudos
Message 2 of 9
(4,140 Views)

Thanks a lot for the reply, which allowed me to arrive at the solution to my problem : right-click on the "target class" node of the "To More Specific Class" to create a constant and then select the class (which can be abstract). Smiley Happy

0 Kudos
Message 3 of 9
(4,108 Views)

You should then mark Nathan's response as the solution, rather than your thank you message. You can unmark a post as the solution using the Options menu on the right, above the message.

0 Kudos
Message 4 of 9
(4,092 Views)

Well ... the answer is not 100% correct because it requires to select a property of the class (or at least the solution I found starting from what was proposed is a better solution) ... so to my humble opinion the solution is located "at the right place" and as such the link to take others to the solution is correct too (and includes credits to the one who pointed my in the direction of the solution) Smiley Wink

0 Kudos
Message 5 of 9
(4,080 Views)

@smercurio_fc wrote:

You should then mark Nathan's response as the solution, rather than your thank you message. You can unmark a post as the solution using the Options menu on the right, above the message.



At least he didn't have the audacity to give Kudo to himself. You see all kinds on this message board. Giving himself credit for a solution he didn't think of in the first place is ridiculous.

 

0 Kudos
Message 6 of 9
(4,071 Views)

I must say I'm "speechless" based on the last reply ... it was never my intention to take any credit and I was even unaware of things like Kudo ... I tagged the initial answer as solution ...

0 Kudos
Message 7 of 9
(4,068 Views)

Glad I could help (and it doesn't matter to me what gets tagged as the solution).  By way of explanation, the reason I suggested a property node is that if you drop the "To More Specific Class" function on the block diagram and create a constant from it without first wiring a .NET object, you'll get a reference to a LabVIEW object instead.  If you use a property node from the .NET palette, you get a .NET class reference (and you do not need to select a property or even wire it to a specific .NET class first). 

0 Kudos
Message 8 of 9
(4,050 Views)

Thanks for the additional explanation Smiley Wink ... fully understood (also the implicit part to throw away the property node afterwards)

0 Kudos
Message 9 of 9
(4,042 Views)