From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Error initializing "new board0" / vb.net

Hi,

I'm trying to find all listeners on board0 in my system using vb.net. I'm using the .net drivers included in ni488.2 distibution.

If I use a similar approach as with a GPIB device (Which works), I'll get the following error:

"An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format."

The 2. line in the following code gives the error:
1: Dim board0 As NationalInstruments.NI4882.Board
2: board0 = New NationalInstruments.NI4882.Board
3: board0.FindListeners()


Have I misunderstood something basic here? (different way of initializing board/device?)

-Øystein
0 Kudos
Message 1 of 9
(4,878 Views)
I still need help on this, any ideas?


-Øystein
0 Kudos
Message 2 of 9
(4,833 Views)
Hi,


Seems like I have to go back to using langInt, for board0 acess, unless someone know how to access boead0 using vb.net drivers (measurement studio .net /included in 488.2)

Any help would be highly appreciated!


-Øystein
0 Kudos
Message 3 of 9
(4,769 Views)
I am not able to reproduce the exception you are getting on a test machine. Can you provide the following information for me:
What version of NI-488.2 is installed on your machine?
What version of the NI-488.2 .NET class library is installed on your machine? (You can check in the GAC or
C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Assemblies\Current\NationalInstruments.NI3882.dll)
0 Kudos
Message 4 of 9
(4,752 Views)
Hi Glenn,

thanks for the reply!



I'm using:
NI-488.2 v2.3
NI-488.2.NET v7.0.0.341


I've tried the same code on a freshly installed
machine, and the same error occures... (I'm using
USB-GPIB adapter)


-Øystein
0 Kudos
Message 5 of 9
(4,688 Views)
I didn't realize you were using a usb-GPIB adapter... I was running the code against a PCI-GPIB board. I will try and get a usb-gpib adapter and re-rerun. Is the code you posted exactly what you're running, or was it meant as a representative sample of what caused the problem? Also, can you run the code in debug mode and let me know what the stack trace is when the exception is thrown?
0 Kudos
Message 6 of 9
(4,684 Views)
Hi,

-I get the following exeption:
"System.FormatException: Input string was not in a correct format.
at System.Number.ParseDouble(String s, NumberStyles style, NumberFormatInfo info)
at System.Double.Parse(String s, NumberStyles style, IFormatProvider provider)
at System.Double.Parse(String s)
at System.Convert.ToDouble(String value)
at a..ctor(Int32 boardIndex, Object sender)
at a..ctor(Object sender)
at NationalInstruments.NI4882.Board..ctor()
at testQuery.Form1.GPIBlist_Click(Object sender, EventArgs e) in c:\gpib\vb_projects\testQuery\testQuery\Form1.vb:line 96"



-Using enironment.stacktrace @ exeption:
"at System.Environment.GetStackTrace(Exception e)
at System.Environment.GetStackTrace(Exception e)
at System.Environment.get_StackTrace()
at testQuery.Form1.GPIBlist_Click(Object sender, EventArgs e) in c:\gpib\vb_projects\testQuery\testQuery\Form1.vb:line 103
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at testQuery.Form1.Main() in c:\gpib\vb_projects\testQuery\testQuery\Form1.vb:line 8"


-Tried the code on a pc with pci-GPIB; same result.

-I'm using only the 3 lines of code described (+ a command button to start it with...)


Thanks for Your help so far!

-Øystein

Message Edited by oystein on 04-11-2005 05:31 AM

0 Kudos
Message 7 of 9
(4,648 Views)
OK, the stack trace helped a lot.

I think I've narrowed down the line of code causing the problem. Can you tell me what's in the following registry key:

HKEY_LOCAL_MACHINE\Software\National Instruments\NI-488.2M\CurrentVersion? I'm assuming it's something like "2.30"

And, are you running this on a localized version of Windows?

I believe that the error is due to the fact that .NET string manipulation is done by default using the machine's current culture. If that culture uses a commas instead of decimal point to separate the integer and fractional part of a number, then parsing that regsitry value to a double is going to fail because it's expecting "2,30", not "2.30".

So one way to confirm that would be to change that registry value to "2,30" and see if your program runs successfully.
0 Kudos
Message 8 of 9
(4,632 Views)
Hi Glenn,

good news!


I've tried to change windows-region to: English(UK) (It was: Norwegian), which resulted in another error:

"System.InvalidOperationException: Method requires GPIB interface to be CIC ---> NationalInstruments.NI4882.GpibException: Method requires GPIB interface to be CIC
--- End of inner exception stack trace ---
at d.a(GpibStatusFlags )
at b.c(GpibStatusFlags )
at a.c(GpibStatusFlags )
at a.e(AddressCollection )
at a.R()
at NationalInstruments.NI4882.Board.FindListeners()
at testQuery.Form1.GPIBlist_Click(Object sender, EventArgs e) in c:\gpib\vb_projects\testQuery\testQuery\Form1.vb:line 102"



After searching ni-forum, I found the following thread:
http://forums.ni.com/ni/board/message?board.id=232&message.id=1078&query.id=3116#M1078


Adding the following line to my code:
"Dim dev As New Device(0, 0)"
, everything worked!



Thanks again for Your quick reply Glenn!


-Øystein
0 Kudos
Message 9 of 9
(4,625 Views)