System.InvalidCastException Agilent Driver .NET

matthew29

New member
Joined
Mar 15, 2012
Messages
2
Programming Experience
3-5
We are using Agilent U2353A driver for the lab. The drivers have intergration features with .NET framework.


I'm trying to invoke the Agilent driver functions from my VB.NET Scripts. When we do the same steps manually, the interface is working fine. But, if it is controlled by another test VB.NET Scripts, it is not permitting me to access the driver functions. Everytime, i get the error as shown below:






System.InvalidCastException was unhandled
Message=Unable to cast COM object of type 'Agilent.AgilentU235x.Interop.AgilentU235xClass' to interface type 'Agilent.AgilentU235x.Interop.IAgilentU235x2'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{43B06E80-AC83-48B6-88FD-D4119CE5F021}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Source=mscorlib
StackTrace:
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, Boolean& pfNeedsRelease)
at Agilent.AgilentU235x.Interop.AgilentU235xClass.get_AnalogIn()
at GBX_Sys_Sim.Drivers_IVI.ADC_Read_DC_Voltage_IVI(Int16 UUT_IO) in C:\Matthew\20120307\WC\Copy of GBX Sys Sim\Drivers_IVI.vb:line 304
at GBX_Sys_Sim.SysSim.ScanAllOutputs() in C:\Matthew\20120307\WC\Copy of GBX Sys Sim\SysSim.vb:line 247
at GBX_Sys_Sim.read_write_sim.update_Sim_output_val() in C:\Matthew\20120307\WC\Copy of GBX Sys Sim\server_Module.vb:line 232
at GBX_Sys_Sim.read_write_sim.ScriptThreadFunc() in C:\Matthew\20120307\WC\Copy of GBX Sys Sim\server_Module.vb:line 92
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:




snapshot of the error is attachedView attachment exception Driver IVI.pdf View attachment exception Driver IVI.pdf


Any idea why this error is occuring.
 
The issue seems fairly clear to me. You have defined your variable as one type and the object you are assigning to it is not that type.

By the way, please just attach images to your posts in future, so we can seem then without having to do anything at all. Downloading and opening a PDF may not be much hassle but nothing at all is less.
 
We performed in two approaches to check if the executable(nothing but the VB.NET Form which can interact with Agilent drivers to read voltages and current) is working.

1. Manual Method: We took the executable and placed breakpoint at that particular location and tried to find what is the value of the object in the watch window. It worked fine and we were able to see that the values are getting updated.

2. Automated Method: We had a script interface which can interact with the executable via Interprocess Communication. We tried to place a breakpoint in the executable project and tried to observe the same parameters. But it is not allowing us to access the parameters. Not sure why it is not able to communicate while we are trying to access via scripts.
 
Back
Top