03-23-2021 04:37 AM
Hi NI Team,
I have a problem with the call of a DLL (.NET) function in LabView.
This function is blocking and sends multiple messages via USB Dongle and receives multiple messages via USB Dongle.
But it seems that the function starts normally but than stopps and will restart again before the function is complete.
In a regular C# program the DLL works pretty good.
Is there any special handling for DLL functions inside of Labview?
Thanks for your help.
Regards
03-23-2021 04:50 AM - edited 03-23-2021 04:55 AM
There are many possible complications when loading a .Net assembly. ( I assume it is a .Net assembly as I don't have a LabVIEW 2020 installation at the moment to look at your VI).
For instance it could be problematic if your assembly requires .Net Framework 2.0 to be loaded. https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YIQoCAO&l=nl-NL
LabVIEW by default loads with .Net Framework 4.0 or newer since about LabVIEW 2014 or so. Depending what your assembly does (PInvoke of unprotected APIs for instance, there are a zillion other possible problems that might not work in how LabVIEW by default sets up the COM threading model, etc. etc. on startup).
The fact that it is supposedly accessing a dongle is most likely not helping either. It may use special tricks to make reverse engineering more difficult and that may involve less than standard compatible code execution that could very well bite with how a complex system like LabVIEW is setting up various Windows facilities in order to support its own needs. The behaviour you see may be an overzealous anti-tampering mechanisme inside that DLL.
03-23-2021 10:17 AM
Your creating an new object in a loop, without closing it.
Bad idea.
First, close references that you open.
Second, open it once, do your things, close it.
03-24-2021 01:30 AM - edited 03-24-2021 02:29 AM
Hi,
thanks for answer. doesn't work the way I want. this is last project.
best regard.
03-24-2021 02:33 AM - edited 03-24-2021 02:38 AM
duplicate
03-24-2021 02:37 AM
You still open (and now at least close) the object at every loop iteration. Put that constructor and Close reference outside of the loop. And I’m pretty sure you would have to do some kind of configuration on the object reference so it knows what hardware interface and communication speed etc.to use for the actual CAN read and write operations. This configuration also needs to happen outside of the loop before you enter the loop!