Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

System.Reflection.TargetInvocationException in communication via GPIB-USB-HS

Solved!
Go to solution

Hi there. I am trying write code in VB.net language and communicate with Keithley electrometer via GPIB-USB-HS with NI-VISA language.While debugging my vbproj codes, I encounterer the following message; "System.Reflection.TargetInvocationException, COM target does not implement IDispatch.". I wonder what it does mean and how to work it around.

 

The related statement is "DMM.IO = RM.Open("GPIB0::21::INSTR)". One could communicate with it via NI-MAX. So, I guess the problem probably stems from that I am not familiar with NI-VISA language.

 

Dim RM As Ivi. Visa.Interop.ResourceManager

Dim DMM As Ivi.Visa.Interop.FormattedIO488

RM = New Ivi.Visa.Interop.ResourceManager

DMM = New Ivi.Visa.Interop.FormattedIO488

DMM.IO = RM.Open("GPIB0::21::INSTR) ' Here is an error generated point!

 

Thanks in advance for your kind advice.

0 Kudos
Message 1 of 5
(2,830 Views)

Have you looked at the example provided by NI ?

C:\Users\Public\Documents\National Instruments\NI-VISA\Examples\DotNET4.0\SimpleReadWrite\vb

0 Kudos
Message 2 of 5
(2,731 Views)

have you looked at the example program

C:\Users\Public\Documents\National Instruments\NI-VISA\Examples\DotNET4.0\SimpleReadWrite\vb

0 Kudos
Message 3 of 5
(2,730 Views)

Thanks! I tried to copy and paste the example program. While pasting it, my Visual Studio environment generated a warning (System.Reflection.TargetInvocationException). I am using Visual Studio 2019 (free-of-charge version). Should I downgrade the VS to, for example, 2011? How can I downgrade?

0 Kudos
Message 4 of 5
(2,721 Views)
Solution
Accepted by ishihamayutaro1

There should be installed examples for newer .NET Framework.

 

0 Kudos
Message 5 of 5
(2,713 Views)