M. Shahini
2008-08-06 15:40:10 UTC
This is my first time making a DLL and programming in C++, so please bear with me if I had made some fundamental mistakes.
I have made a DLL that reads images and performs Canny edge detection using the OpenCV libraries.
So I made a very simple LabVIEW program to test it (just a lib node with inputs and one output).
It worked fine, so I saved and quit. HOWEVER, when I restarted LabVIEW again and ran the same program,
it almost stopped working when the signal reached the Node and generated Error 1097:
----
Error 1097 occurred in Call Library Function Node in Canny.dll:
An exception occurred within the external code called by the Call Library Function Node.
The exception may have corrupted LabVIEW's memory.
Save any work to a new location and restart LabVIEW.
----
The only way I got it to work again was to:
1) copy and paste the program contents into a new file without any other modification, save and run.
2) change the DLL within the node configurations to any other DLL; this could also mean an exact copy of the DLL.
It worked once again, as long as LabVIEW.exe was not restarted; i.e. I could close the VI and reopen it
as many time as I wanted and it still works, but when I shut LabVIEW
off, restart it and reopen the same VI, it generates the above error.
I made a C++ program that calls the DLL, and it works fine, regardless of when and how many times it was called.
I also tried debugging it in Visual Studio and that worked fine too, regardless of when and how many times it was called.
Because of this, coupled with the fact that DLL works any amount of times in LabVIEW in a new VI, convinces me that
the settings of the node and the programming within the DLL code is
correct (code is still available on request, nothing propietary).
I have a feeling that it might have to do with how LabVIEW deals with its own memory preallocation/pointer validation
(apart from what is done in the DLL), or even a bug in LabVIEW, but I'm not sure.
Any help would be appreciated. Many thanks in advance.
I have made a DLL that reads images and performs Canny edge detection using the OpenCV libraries.
So I made a very simple LabVIEW program to test it (just a lib node with inputs and one output).
It worked fine, so I saved and quit. HOWEVER, when I restarted LabVIEW again and ran the same program,
it almost stopped working when the signal reached the Node and generated Error 1097:
----
Error 1097 occurred in Call Library Function Node in Canny.dll:
An exception occurred within the external code called by the Call Library Function Node.
The exception may have corrupted LabVIEW's memory.
Save any work to a new location and restart LabVIEW.
----
The only way I got it to work again was to:
1) copy and paste the program contents into a new file without any other modification, save and run.
2) change the DLL within the node configurations to any other DLL; this could also mean an exact copy of the DLL.
It worked once again, as long as LabVIEW.exe was not restarted; i.e. I could close the VI and reopen it
as many time as I wanted and it still works, but when I shut LabVIEW
off, restart it and reopen the same VI, it generates the above error.
I made a C++ program that calls the DLL, and it works fine, regardless of when and how many times it was called.
I also tried debugging it in Visual Studio and that worked fine too, regardless of when and how many times it was called.
Because of this, coupled with the fact that DLL works any amount of times in LabVIEW in a new VI, convinces me that
the settings of the node and the programming within the DLL code is
correct (code is still available on request, nothing propietary).
I have a feeling that it might have to do with how LabVIEW deals with its own memory preallocation/pointer validation
(apart from what is done in the DLL), or even a bug in LabVIEW, but I'm not sure.
Any help would be appreciated. Many thanks in advance.