取消
显示结果 
搜索替代 
您的意思是: 

Scripting a .NET Constructor Node in LabVIEW

已解决!
转到解答

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 项奖励
1 条消息(共 4 条)
4,055 次查看
解答
已被主题作者 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.

2 条消息(共 4 条)
3,982 次查看

That works 🙂 Thanks a lot!

------
Using LabVIEW since 2012. Certified LabVIEW & TestStand Architect
0 项奖励
3 条消息(共 4 条)
3,938 次查看

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 项奖励
4 条消息(共 4 条)
3,855 次查看