LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW & .NET Exceptions

Solved!
Go to solution

Here's a snippit on LabVIEW and .NET Exceptions

 

http://digital.ni.com/public.nsf/allkb/B15CE9F2715434C386256D3500601878

 

"In LabVIEW 8.0, more information was added to the error messages by placing the .NET Exception Message property into the error source string in the error cluster. By having this extra information, it is easier to diagnose the root cause of the problem.

Note: In LabVIEW 8.0 and later, you will only receive the extra information if you use proper error handling."

 

 

My question:

 

What is "proper error handling"? Sure, I can put all my .NET code in a try-catch statement, but how should I best export .NET errors from my .NET class (in a DLL using LV's .NET interface tools) to LabVIEW's error terminals?

 

What I want is for my .NET exception to be caught and passed into LabVIEW directly into the error terminal.

0 Kudos
Message 1 of 4
(3,060 Views)
Solution
Accepted by topic author PConrad
"proper error handling" refers to actually wiring the error clusters through the .NET property and method nodes. A lot of times you see folks plopping down .NET property and method nodes and not wire up the error clusters, so you will never know if an exception occurred.
Message 2 of 4
(3,057 Views)

I always hook up the error terminals properly, so I'm covered there.

 

But what do I need to do in my .NET program to properly tunnel the error out? Do I NOT use a try-catch and just let the code throw an exception?

 

If I have a method in a class...

 

public class Foo

{

public static void Bar()

{

throw new Exception("BlahBlahBlah")

}

}

 

...and I run Foo.Bar() from LabVIEW, will my exception get sent through the Method node's error terminals.

0 Kudos
Message 3 of 4
(3,054 Views)
Pretty much if the code doesn't throw an exception, then there's nothing for LabVIEW to "catch". Basically, you can consider LabVIEW as the top-level "catch" block if your code doesn't catch the exception.
Message 4 of 4
(3,034 Views)