05-28-2014 12:02 PM
When I exit my application, the call to dispose a message base session hung (mbSession.Dispose())
Can anyone help me with this problem?
Thank you,
David
05-29-2014 04:25 PM
You didn't give us a lot of information to go on. Have you tried looking at/running any of the example programs for .NET Instrument Control? They might give you an idea of what you're doing wrong. They install with VISA and can be found at Start->All Programs->National Instruments->VISA->Examples.
This document also provides a .NET Instrument Control Tutorial. Try working through the tutorial and see if you get the same results.
03-06-2015 02:32 PM
I've got the same issue using visual studio 2013 and .NET 4.5.
Using VisaNS version 13.0.45.167
In my app I have a messagebox just after calling the function below. I never see the messagebox mbSession.Dispose(); never returns
public void OpenSession(string visaName) //Opens and closes a session used for initial debug
{
try
{
mbSession = (MessageBasedSession)ResourceManager.GetLocalManager().Open(visaName);
mbSession.Dispose();
}
catch (InvalidCastException)
{
MessageBox.Show("Resource selected must be a message-based session");
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}
Any help would be appreciated
03-09-2015 11:41 AM
Hi tde_boiler,
There are a few things I can suggest for you to try:
1. Try running an instrument example program to make sure that your computer is configured correctly (as mentioned above).
2. In the tutorial, they don't have the Dispose() call inside the try / catch statement- it shouldn't make a difference, but try calling Dispose() after the try / catch.
3. You could try breaking up the line containing Open(), so that you can step through each method to see if the session is being correctly set up.
Thanks,
Andrew
03-09-2015 11:52 AM
Thanks Andrew,
I appear to failing at suggestion 1.
the example below from NI does the exact same thing. Once I click the close button in the example program it hangs there and never exits out of the Dispose() method.
...\National Instruments\NI-VISA\Examples\DotNET4.5\SimpleReadWrite\cs
03-09-2015 12:03 PM - edited 03-09-2015 12:04 PM
And the fix is in the message board below. Root Cause. Agilent/Kesight Visa and NI-Visa do not play nice together in .NET.