LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Catch error from labview build dll

Hello!
We have made a dll in LabView 8 that is called from a C++ program. How can the C++ program know that there have been no "exception" error? Normally you can have a try-catch of exception errors but I can not find a function like that in the dll.
/tj
0 Kudos
Message 1 of 3
(2,960 Views)
Do you mean having the LabVIEW DLL "throw" an exception that you can "catch" in your C++ program? LabVIEW doesn't really have a "throw" operation in that sense. You could look at the error out cluster in your C++ code to see if the LabVIEW code generated an error, assuming you used the error clusters in your LabVIEW code.
0 Kudos
Message 2 of 3
(2,952 Views)

I've been struggling with trying to pass error cluster data in and out of a Labview 7.1-built DLL from a C# program.  I've found many entries in the discussion forum that come close to answering my problem but most of the discussions are dealing with C or C++ or they are dealing with passing the data from Labview to a DLL made by C or C++.  Since this discussion is the most recent I've found that closely resembles my problem I'm jumping into this thread in hopes that maybe someone can help me out.

One of the challenges with C# is that you have limited use of pointers in "unsafe" code blocks. The C definitions associated with the Labview error cluster are:

typedef

struct { // The Error Cluster as a structure
LVBoolean status;
int32 code;
LStrHandle source;
} TD1;

typedef struct { // The String member of the error cluster as a structure
int32 cnt;
/* number of bytes that follow */
uChar str[
1]; /* cnt bytes */
} LStr, *LStrPtr, **LStrHandle;

Note that the string member is really a Handle, .i.e., a pointer to a pointer.  C# doesn't allow the use of pointers to managed data like Strings and Arrays.  It also doesn't allow pointers to structures containing managed data.  I have been unable to find a way to marshal data from the "unmanaged" DLL code to the "managed" C# code.  I have been able to marshal in a Labview string when it is a separate parameter.  The problem occurs when the LV string is a member of a cluster.

0 Kudos
Message 3 of 3
(2,896 Views)