05-30-2021 07:16 AM
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 🙂
Solved! Go to Solution.
05-31-2021 03:43 PM - edited 05-31-2021 03:48 PM
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.
06-03-2021 03:21 AM
That works 🙂 Thanks a lot!
08-31-2021 04:47 AM
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 🙂