Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

System.ArgumentException in NationalInstruments.VisaNS.dll, VISA error code -1073807330 (0xBFFF001E), ErrorNonsupportedAttributeState

Hi all,

 

I am evaluating Measurement Studio 2012 with MS Visual Studio 2010 Professional and VISA 5.2 on a Windows 7 64-bit based PC

 

I have a strange error when I try to run the simplest program which uses the NationalInstruments.VisaNS assembly in Visual C# 2010; following the instruction contained in the Getting Started with Measurement Studio 2010 - Support for Visual Studio 2010, page 2-50 (Walkthrough: Creating a Measurement Studio Instrument I/O Application) to launch a simple *IDN? query to an instrument, at runtime I systematically receive the following error

 

An unhandled exception of type 'System.ArgumentException' occurred in NationalInstruments.VisaNS.dll
Additional information: The specified state of the attribute is not valid, or is not supported as defined by the resource.  VISA error code -1073807330 (0xBFFF001E), ErrorNonsupportedAttributeState

 

Debugging the code I see that the exception is rised by the instruction

 

_reader = new MessageBasedSessionReader(_instrumentSession);

 

in VisaTask.mxb

 

Using the NI I/O Trace I captured the following calls to the VISA library:

 

1.  viOpenDefaultRM (0x00001001)
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:47.546       Call Duration 00:00:00.023
Status: 0 (VI_SUCCESS)

2.  viParseRsrcEx (0x00001001, "USB0::0x0957::0...43004870::INSTR", 7, 0, "INSTR", "USB0::0x0957::0...04870::0::INSTR", "")
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:47.577       Call Duration 00:00:00.001
Status: 0 (VI_SUCCESS)

3.  viClose (0x00001001)
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:47.581       Call Duration 00:00:00.001
Status: 0 (VI_SUCCESS)

4.  viOpenDefaultRM (0x00001001)
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:47.587       Call Duration 00:00:00.005
Status: 0 (VI_SUCCESS)

5.  viParseRsrcEx (0x00001001, "USB0::0x0957::0...43004870::INSTR", 7, 0, "INSTR", "USB0::0x0957::0...04870::0::INSTR", "")
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:47.596       Call Duration 00:00:00.001
Status: 0 (VI_SUCCESS)

6.  viOpen (0x00001001, "USB0::0x0957::0...04870::0::INSTR", 0, 0, 0x00000001)
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:47.597       Call Duration 00:00:00.010
Status: 0 (VI_SUCCESS)

7.  viInstallHandler (USB0::0x0957::0x0407::MY... (0x00000001), IO_COMPLETION, 0x000007FEFB6B5D00, 0x000000001C3A05C0)
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:47.627       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

8.  viSetAttribute (USB0::0x0957::0x0407::MY... (0x00000001), TMO_VALUE, 2000)
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:47.631       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

9.  viSetAttribute (USB0::0x0957::0x0407::MY... (0x00000001), TERMCHAR_EN, VI_TRUE)
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:47.637       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

10.  viSetAttribute (USB0::0x0957::0x0407::MY... (0x00000001), TERMCHAR, 10)
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:47.640       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

> 11.  viSetAttribute (USB0::0x0957::0x0407::MY... (0x00000001), RD_BUF_OPER_MODE, 3)
> Process ID: 0x000008DC         Thread ID: 0x00000B3C
> Start Time: 15:48:47.646       Call Duration 00:00:00.000
> Status: 0xBFFF001E (VI_ERROR_NSUP_ATTR_STATE)

12.  viStatusDesc (USB0::0x0957::0x0407::MY... (0x00000001), 0xBFFF001E, "The specified s...y the resource.")
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:47.650       Call Duration 00:00:00.001
Status: 0 (VI_SUCCESS)

13.  viGetAttribute (USB0::0x0957::0x0407::MY... (0x00000001), RSRC_NAME, "USB0::0x0957::0...43004870::INSTR")
Process ID: 0x000008DC         Thread ID: 0x00000B3C
Start Time: 15:48:48.054       Call Duration 00:00:00.001
Status: 0 (VI_SUCCESS)

Step 11 is the only one marked in red; the problem seems to be related to an improper value assigned to property RD_BUF_OPER_MODE (3 = VI_FLUSH_DISABLE).

 

The strange aspect of the problem is that this exception is not raised when I test the command sequence in the instrument I/O assistant at design time (step 11 does not appear at all at that time in calling sequence).

 

The instrument used in the test is simply an Agilent's 33220A Arbitrary Function Generator and the problem arise whatever bus (GPIB, USB, Ethernet) I use to connect it to the PC.

 

 

Is there someone else which has had the same problem with VisaNS?

 

Any hint will be appreciated!

 

 

0 Kudos
Message 1 of 7
(7,873 Views)

Hi,

 

Did you try to handle a simple query as "*IDN?" through MAX (Measurement and Automation Explorer) software? The error persists? Which is the baud rate that you are using right now? 

 

How does VISA set baud rates for serial boards?

http://ae.natinst.com/public.nsf/web/searchinternal/5d2b2f533cfd001586256efc00823580?OpenDocument

 

Have a good time!

 

 

 

 

0 Kudos
Message 2 of 7
(7,848 Views)

Dear enpe,

 

thank you for your reply but the problem seems to be not related to the serial interface because I don't use it at all (the Agilent 33220A does not have a serial interface as the previous model 33210A); the error arise when I use anyone of the GPIB/USB/Ethernet connection of the instrument and only at run-time when I use the code automatically generated by the Instrument I/O Assistant in Visual Studio.

 

When I check the correctness of the query (a simple *IDN?) at design time, all goes right (the instrument responds and no error is intercepted in NI I/O Trace); all goes right also when I use MAX.

 

I think it could be some incompatibility issue between Measurement Studio 2012 and NI-VISA v5.2 (the latest available for download on the NI website), but I have had no time to try to make a downgrade at a previous version.

 

Thank you again for your willingness.

 

Regards

 

0 Kudos
Message 3 of 7
(7,842 Views)

Hi Frada,

 

We recently discovered an issue with the VisaNS class library and .NET Framework 4.5. The issue occurs for applications running in the .NET 4.0 CLR on systems that have .NET 4.5 installed. The application does not need to be targetting .NET 4.5 for the issue to occur. You can find more details about the issue here, as well as some possible workarounds.

 

The issue manifests as an ArgumentException with VISA error code -1073807330, which is why I suspect that you are running into this issue. Do you know if .NET Framework 4.5 is installed on your target system?

National Instruments
0 Kudos
Message 4 of 7
(7,743 Views)

Dear D_Biel,

 

thank you very much for your answer; yes I just verified that I have Microsoft .NET Framework 4.5 installed on my system...

 

As per the only workaround available suggested on the technical article you linked in your answer, I will try to uninstall that version of .NET Framework to see if this solves the problem with VisaNS; however, in these days I am out of lab, so I will be unable to verify the correctness of this workaround in my case.

 

I will post a report on this thread as soon as possible.

 

Thank you again for your answer; regards.

 

0 Kudos
Message 5 of 7
(7,738 Views)

Please let me know how that turns out. Also, if you are not using either any of the listed methods, then you can workaround the issue for the properties by using the SetAttributeInt32 method with the listed AttributeType. This would prevent you from running into this issue on other systems or at a later time if .NET 4.5 gets installed again.

National Instruments
0 Kudos
Message 6 of 7
(7,736 Views)

Dear D_Biel,

 

finally, after the verification I just made in my laboratory, I can inform you that my problem with VISANS.dll was due in all likelihood to the cohexistence of Microsoft .NET Framework v4.0 and v4.5; unistalling the Framework v4.5 the VISANS-based instrument control application started to work correctly without errors.

 

Thank you for your assistance; best regards.

0 Kudos
Message 7 of 7
(7,668 Views)