LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you check for a null result from a .Net method call?

I have a .Net assembly that contains a class that I am constructing in a VI. I am calling a method that returns an instance of a .Net class. For the sake of argument, let's say the method is GetUser and it returns a Person object. When I call the method, it may return null if the specified Person is not found. How can I ckeck for a null value so I can handle that possibility before I try to access the Person's properties? Is that even possible?

( Disclosure: I wrote the .Net assembly, I am not really the VI programmer, but I'm trying to find the answer for my collegue who is writing a VI against my code. Thanks! )


Message Edited by Todd Moon on 12-19-2007 10:41 AM
0 Kudos
Message 1 of 4
(3,362 Views)
The comparison palette has a Not a Number\Path\Refnum? primitive which returns a boolean output. I don't remember off hand if it works with .NET references, but the documentation and a simple test should provide an answer. Even if that doesn't work, you can provide a simple method which will accept an object and return a boolean.

Additionally, I'm not sure if .NET methods can have multiple return parameters, but if they can, you can add a boolean output.

___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(3,348 Views)
I can confirm that the Not a Number\Path\Refnum? primitive will work as advertised. I've used it on .NET assemblies I've written.

Unfortunately, a .NET method cannot return multiple parameters. It's just like a regular "C" function call with a single return value, which can be just about any datatype.
0 Kudos
Message 3 of 4
(3,341 Views)
Thanks! I'll pass that on!
0 Kudos
Message 4 of 4
(3,337 Views)