LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview 2012 .Net Exception Handling

We are using LV 2012 and trying to capture a .Net exception and display the contents of the Message property on the Exception object. We have been unsuccessful thus far. Is there some prescribed approach for getting this to work?

 

We're capturing the exception and we have a property node for the Message but it's not working.

 

I've modified the .Net classes, adding an ErrorMessage property that can be inspected for a value but this isn't optimal and forces us to use hokey code in our other .Net apps that need to consume the same assemblies rather than just catching exceptions and I'd rather not use this approach.

 

Any assistance would be greatly appreciated.

 

Thank you

0 Kudos
Message 1 of 4
(2,769 Views)

Hello,

       

-          Please check a couple of details following this information:

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

-          Also, please check this forum:

-          http://forums.ni.com/t5/LabVIEW/Force-net-exceptions-to-the-LabVIEW-error-cluster/td-p/603018

-          Now, you may wonder what's the best way to programmatically access the exception information: One suggestion is to put try/catch blocks around your assembly methods and return the exception object from the method call or return null if no exception occurred. This gives you a reference to the exception object and thus you can do all sorts of programmatic handling.  Now that you have this .NET exception object, you have full access to properties like InnerException, Message, Source, StackTrace, etc and access to the methods and type information.  Another suggestion is if access to the assembly or object instance is single-threaded, then you could have some sort of Last Error property on the object that you could query if you get an error in the error cluster.

 

Regards

0 Kudos
Message 2 of 4
(2,749 Views)

Thank you. I have looked at both of these posts. Currently, I have added an ErrorMessage property to the object being returned. However, this isn't a very elegant solution. Additionally, placing a try/catch block around the .Net code and then returning the Exception object doesn't work when the method definition has declared a different return type. I was basically trying to determine whether LV supports the same premise of catching an exception and then displaying the message vs having to add an ErrorMessage property to all of the object types that may be returned to LV and then have to inspect that property, in LV, to determine whether an error occurred.

 

Thanks

0 Kudos
Message 3 of 4
(2,743 Views)

Hi Pothole, I understand why you were looking for other solution.

So to summarize how LabVIEW handles .NET exceptions:

.NET exceptions

 

Regards

0 Kudos
Message 4 of 4
(2,727 Views)