Measurement Studio for .NET Languages

Showing results for 
Search instead for 
Did you mean: 

Open / connection status



I am new to C# but have made some GPIB Instrument control in C++ some 10 years ago so I am not a hardcore programmer.


My problem is that I want to open a connection to an instrument and then detect if it is there.

If it is not there then I want exit the function.

I have not been able to figure-out how to get the handle status back.


I have been looking for a handle that is “null” but found nothing.

And I have been looking for “exceptions” and made some “try and error” but without success.


Anyone that can help.



I am using the VisaNS.



using NationalInstruments.VisaNS;


public void Get_IDN(int i)


     string responseString;


     gSession = (GpibSession)ResourceManager.GetLocalManager().Open("GPIB0::20::INSTR");


     responseString = gSession.Query("*IDN?\n");






0 Kudos
Message 1 of 3

Look at the examples in C:\Users\Public\Public Documents\National Instruments\NI-VISA\Examples\DotNET4.0\



0 Kudos
Message 2 of 3

Hej nyc thanks.


I have already been looking on these examples and that was what led me to look for exceptions. More precise I tried to catch "VisaException" but with no luck.

It never registrated any exception though no instrument was connected.


So am I searching in the wrong direction.





0 Kudos
Message 3 of 3