From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

throwing exceptions from a labview dll

I have created a vi in labview 8.2 and compiled the project with this single vi into a dll.  Then I have a C# code, which calls the vi as a function call.  The simple example I have created works fine.  At this point I would like to extend my example to explore error handling and callback functions.  
 
1.  Is it possible to "throw" an exception from a Labview VI, that was compiled into the DLL, and catch it in my C# code, which makes the call?  ...How can I do this? 
 
2.  Is it possible to pass a "callback" pointer to my Labview DLL function, so that when I call the function from C#, I can have the Labview DLL function execute my "callback" function? 
 
3.  Where can I read about the limitations of interfacing from C# to Labview DLLs (I could not find the answers to my questions in the Help files)?
 
Thanks,
Gene Fridman
 
 
 
0 Kudos
Message 1 of 2
(2,301 Views)
Gene,


"1.Is it possible to "throw" an exception from a Labview VI, that was compiled into the DLL, and catch it in my C# code, which makes the call? ...How can I do this?"


Not with native LabVIEW (perhaps if you misuse one of the exported functions, but it will be experimental). But you can make a c++ or assembler dll with a devide by zero in it, or an int 2 or something to trigger the exeption. It just might work...


"2. Is it possible to pass a "callback" pointer to my Labview DLL function, so that when I call the function from C#, I can have the Labview DLL function execute my "callback" function?"


If you want the LabVIEW function to act as the callback, you can use LoadLibrary and GetProcAddress to get a pointer to the LabVIEW dll function.


If you want the C# function to be called from LabVIEW, you'll have to make a export function that makes the call.


"3.Where can I read about the limitations of interfacing from C# to Labview DLLs (I could not find the answers to my questions in the Help files)?"


No idea about that. I guess this forum or LAVA (google "LAVA LabVIEW") would be your best bet.


Regards,


Wiebe.



0 Kudos
Message 2 of 2
(2,298 Views)