10-19-2015 09:24 AM
Hi everyone,
I've been trying to get CVI code to run in Visual Studio using this guide (http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/usermanual/prjbldmenuextcomplrspt/). So far I've been successful. However, I've been struggling with non-fatal runtime errors. Apparently, Visual Studio doesn't track them. Also fatal runtime errors do not produce a meaningful error message. Is there a way to get these error messages from inside Visual Studio? Maybe there's an event/callback whichI can use.
Thanks in advance.
Solved! Go to Solution.
10-20-2015 02:05 AM
Hi!
Can you elaborate what you mean with 'doesnt track [the errors]'? Can you give us a small example of a code producing this behaviour?
Best regards,
Christoph
10-20-2015 09:35 AM
int rc = SetCtrlAttribute(panelHandle, -3, ATTR_LABEL_TEXT, "Hello");
If i execute this code there will appear a non-fatal run-time-error popup. I'm looking for a way to get these notifications working in Visual Studio, too. Of course I can still check the error code but getting an actual message popup is so much more convenient.
10-21-2015 01:22 AM
Hi!
if you are getting the error code indeed but you miss the error message box of visual studio it looks like a function of visual studio for me. In this case I would turn to the Microsoft Support since it is their product and you seem to be referring to a Visual Studio function not a CVI one.
Best regards,
Christoph
10-21-2015 03:01 AM
Thanks for your help.
However, breaking on error codes isn't something I would Visual Studio expect to support out of the box, because how is it supposed to know whether its an error code or an ordinary return value? There's got to be a way to tell the cvi runtime what to do whenever a non-fatal (i.e. return code != 0) happens. I already tried setting it explicitly by calling SetBreakOnLibraryErrors(1). However, this doesn't seem to have an effect in Visual Studio as subsequent calls to GetBreakOnLibraryErrors still return 0.
Kind regards
10-30-2015 11:45 AM
The functionality that you're describing is called "user protection". In addition to reporting error codes in popups, it also warns you if you access invalid memory, pass data types to functions that expect different data types, detects uninitialized local variables, etc...
Unfortunately, user protection only works for programs built in debug mode with the CVI compiler. If you build your source code in Visual Studio, the VC compiler does not inject the information required for user protection to work.
The only possible way that you could get this to work in Visual Studio would be if you could somehow isolate all your CVI code in some DLL that you would build with CVI, and then call this DLL from the rest of your program, which you build with Visual Studio.
Luis
09-13-2023 08:42 AM
I wonder if a conditional breakpoint would work?
VS has no idea what is good or bad return value, but you do. So you set a breakpoint to 'break when [value] <= ERROR_CODE'