Quantcast
Channel: Instrument Control (GPIB, Serial, VISA, IVI) topics
Viewing all articles
Browse latest Browse all 5565

Catch error when creating new device in .NET

$
0
0

I have a .NET Windows application running fine, using C# in Visual Studio with the NI 3.1.2 drivers.  This requires 'namespace NationalInstruments.NI4882'.  I create a new device using 

    device = new Device(boardID, (byte)gpibAddressNumericUpDown.Value);

to access the GPIB device specified in gpibAddressNumericUpDown.Value, and I'm able to read and write from it just fine.

 

Now how do I catch the exception if I put the wrong address in gpibAddressNumericUpDown.Value?  I've tried 

    try {

        device = new Device(boardID, (byte)gpibAddressNumericUpDown.Value);

 

    }

    catch {

    }

and I don't seem to ever enter the 'catch' block.  Object Browser for the NI Device object says something about "exceptions", but I don't know how to check for them or if that's what I want.

 

Thanks for any help!

Gerrit


Viewing all articles
Browse latest Browse all 5565

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>