LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting a .NET Constructor Node in LabVIEW

Solved!
Go to solution

I am trying to set the class constructor for a .NET constructor node using scripting and I am not able to get it to work reliably. 

 

Issue: LabVIEW is not able to set the .NET constructor node programmatically and says "Class Not Found", if the .NET class is not in memory (even if its part of the same active selected .NET DLL). It works only when that specific class constructor is already in memory.

 

Error 1113 occurred at Property Node (arg 2) in Setting .NET Constructor Class.vi

Possible reason(s):

LabVIEW: Internal Error. The external object class was not found.

Property Name: Constructor Node Class Name

 

If I place another .NET constructor node and manually choose the class that I am trying to set, then it gets set. So, it seems that if that specific class is in memory, it works (but not practical for my use case).

 

I am attaching an example VI (LabVIEW 2016) which showcases the issue. Issue is reproducible in LabVIEW 2020 as well. Any help on this would be greatly helpful 🙂

------
Using LabVIEW since 2012. Certified LabVIEW & TestStand Architect
0 Kudos
Message 1 of 4
(3,321 Views)
Solution
Accepted by topic author Karthik_Abiram

You can force LabVIEW to load the .NET assembly in memory using the private App method ".NET.Load Assembly", given the assembly path.

You just need to know where your dll is located (in our case in "C:\Windows").

It will load the whole assembly the first time, then you can set the constructor to any class in the assembly.

Subsenquent calls to this method with the same assembly won't do anything as it is already in memory, and it will stay in memory until LabVIEW is closed.

You cannot normally access this method, unless you add the following key to your LabVIEW.ini : "SuperSecretPrivateSpecialStuff=True".

Be sure to only use this key when doing scripting, as it will add A LOT of additional private methods and properties, which may get you lost during normal development.

Message 2 of 4
(3,248 Views)

That works 🙂 Thanks a lot!

------
Using LabVIEW since 2012. Certified LabVIEW & TestStand Architect
0 Kudos
Message 3 of 4
(3,204 Views)

One more question on the same topic of scripting .NET Constructor programmatically:

 

 If the .NET Constructor class has multiple constructor implementations, how can I select the one that I want via scripting? By default it selects the one at the top - but I am not able to find any scripting nodes to select something else. Any help on this would be greatly helpful 🙂

 

Karthik_Abiram_0-1630403166095.png

 

------
Using LabVIEW since 2012. Certified LabVIEW & TestStand Architect
0 Kudos
Message 4 of 4
(3,121 Views)