Switch Hardware and Software

Showing results for 
Search instead for 
Did you mean: 

NISWITCH_32.dll problem with Visual Basic

I am using a PXI 2532 and I am trying to control the switchboard with some program in Visual Basic.

I am using the latest Microsoft Visual Basic 2008 Express Edition to make my program.

I try to check the example code :
'Open a session to the switch module and set the topology.
niSwitchCheckErr(niSwitch_InitWithTopology(txtResourceName.Text, txtTopology.Text, VI_FALSE, VI_TRUE, switchSession))

'Configures the switch module for scanning. Refer to NI Swtiches Help for scan list syntax.
niSwitchCheckErr(niSwitch_ConfigureScanList(switchSession, txtScanList.Text, NISWITCH_VAL_BREAK_BEFORE_MAKE))

'Configures the input trigger to be software trigger.
niSwitchCheckErr(niSwitch_ConfigureScanTrigger(switchSession, 0, NISWITCH_VAL_SOFTWARE_TRIG, NISWITCH_VAL_NONE))

'Configures the switch to loop continuously through the scan list until niSwitch_Abort is called.
niSwitchCheckErr(niSwitch_SetContinuousScan(switchSession, VI_TRUE))

'Initiates the scan usings the configured scan list and triggers.

But It is not working, as I have to add some reference to my project.

The help says :
Add a reference to the National Instruments Switch Library (NISWITCH), which is part of the NI-SWITCH DLL. In Visual Basic 6.0, select the Project»References menu option and National Instruments Switch Library (NISWITCH). If you do not see NISWITCH listed there, click Browse and locate NISWITCH_32.dll in your IVI\Bin directory.
Use the Object Browser to find function prototypes and constants.
Add NI-SWITCH function calls to your application.

I am adding the reference using the Browse way of doing it. I can see the DLL file and while trying to add it as a reference I have the following error message :

A reference to C:/Program Files/IVI foundation/Bin/NISWITCH_32.dll could not be added. Please make sure that the file is accessible and that it is a valid assembly or COM component

If this component is not the good one, which is the good one I have to add to my project to add the library recognizing the NI functions ?

Thanks for your help

Message Edited by CLU883R on 09-17-2008 02:19 AM
0 Kudos
Message 1 of 3

Hi C.,


.NET will not accept NISWITCH_32.dll because it is a C DLL and .NET requires an assembly or COM component.  I recommend using one of our Visual Basic .NET example programs and the included .NET wrapper.  Once the simple example works, then you can change the code to employ scanning and/or whatever else you might need to accomplish.


Here is a .NET example showing how to make connections on a switch:



I was able to upgrade it simply by opening the .sln with the Microsoft Visual Basic 2008 Express Edition.  Attached, I have shown how to configure Form1 so the program will work with a PXI-2532.


Let me know if you have further questions!


Chad Erickson

Switch Product Support Engineer


0 Kudos
Message 2 of 3
Dear Sir,

The example you gave me contain a file named NiSwitch.vb I think it contains the VB drivers.
So now, with this example, I can use the Niswitch library functions.

Thanks for your quick help and consideration

May I suggest to NI to update their help file to include this link.

Best Regards
0 Kudos
Message 3 of 3