AnsweredAssumed Answered

Unable to get access to IChannel / Channel COM Objects with C#

Question asked by jerome.l.perron on Aug 28, 2018
Latest reply on Aug 28, 2018 by jerome.l.perron



I'm creating a library of functions built with the COM object provided from my PNA (PNA N5227A). I am able to create Measurement enumerations / Measurement objects. However, when I do exactly the same for the IChannel Interface, nothing seems to work.


To start, i have successfully instantiated the AgilentPNA835x.Application under _iDO property (the protected is because I inherit from a generic class which provides me with the objects, though I,ve tried making them public and it still fails to work). From this property, I get my measurement list, and I can create different measurement object within this enumeration: 



protected AgilentPNA835x.IMeasurements _measList;


_measList = _iDO.Measurements;

// Creating S-parameter matrix (using 1 and 2 for an example in the comments)

// S11 on Window 1
_measList.Add(1, "S" + sourcePort.ToString() + sourcePort.ToString(), sourcePort, 1);

// S21 on Window 2
_measList.Add(1, "S" + sourcePort.ToString() + receiverPort.ToString(), sourcePort, 2);

// S12 on Window 2
_measList.Add(1, "S" + receiverPort.ToString() + sourcePort.ToString(), receiverPort, 2);

// S22 on Window 1
_measList.Add(1, "S" + receiverPort.ToString() + receiverPort.ToString(), receiverPort, 1);


string doesNameMethodWork = _measList.Item(1).Name;


Now, all of the above work properly.


Now if I do something very similar with IChannel, I get:

error CS1061: 'IChannel' does not contain a definition for 'StartFrequency' and no extension method 'StartFrequency' accepting a first argument of type 'IChannel' could be found (are you missing a using directive or an assembly reference?)


Here is a code sample:

protected AgilentPNA835x.IChannels _channelList;

AgilentPNA835x.IChannel chan;




chan = _channelList.Item(1);

At this point and time, chan is "not" set to null, but it still tells me that it doesn't contain a definition for members of this object...


I also tried going through the ActiveChannel, from the Application Object:

chan = (AgilentPNA835x.Channel)_iDO.ActiveChannel;


In this specific case, the chan object is set to null... which I don't quite understand. Of course, when set to null, this object won't be able to access properties or methods.


Since everything is working fine while using measurement objects / enumerations, I'm wondering why does the IChannel object behave differently, and how do I fix this issue? The COM object model is a very promising way to handle the PNA, but I need to make these things work out properly.


Thanks a lot for your support,