After creating "GCA" measurements successfully with PNA-x N5242A rev A.10.64.09, But failed to get GCA handle. The code is listed here:
Type pnaType = Type.GetTypeFromProgID("AgilentPNA835x.Application", "N5242A");
AgilentPNA835x.Application pna= (AgilentPNA835x.Application) Activator.CreateInstance(pnaType);
//create an "Gain Compress" object with measurement "CompOut21" on Channel 1. successfully in next line.
AgilentPNA835x.IMeasurement cust_meas = pna.CreateCustomMeasurementEx(1, "Gain Compression", "CompOut21", 1);
// Get current channel.
AgilentPNA835x.IChannel chan= pna.ActiveChannel;
// to change GCA default settings, need to get GCA handle from IChannel in the next line.
AgilentPNA835x.IGainCompression gca =chan.CustomChannelConfiguration()
The question is : CustomChannelConfiguration() property is not visible for current Channel interface "chan" object though we can find CustomChannelConfiguration propriety of AgilentPNA835x.Channelclass from Object Browser.
You have 2 issues in your code above. the first issue is with this line:
In the PNA COM API, when you type an object as an I[some class] (in your case as IChannel), you are declaring that object as a specific numbered instance of that class. IChannel is the very first version of the Channel class, and back when the channel class was first created, there were no custom measurements and therefore that version of the Channel interface doesn't have the CustomChannelConfiguration property. To access that property, you would need to get a version of the IChannel interface that came after we introduced custom measurements. You are using version A.10.64.09 and assuming the PNA proxy on the PC that you are using to run your program matches the version you are running, the latest IChannel interface is IChannel26. To see what the latest version of the interface is for one of the COM objects, just go to the bottom of the help page for that object and there should be an interface history. For example, here is the Channel help page for version A.10.64.xx. So you have 2 options for rewriting the line above:
The 2nd option uses the default interface, which always points to the latest interface version that is available in the proxy DLL that you referenced in your application. The benefit of using the default interface is that you will always get the latest version, but it could also prevent you from running your application against an older version of the firmware, because the latest interface version in your referenced proxy DLL may be a higher number than what is available in the older firmware.
Your 2nd issue is the last line:
CustomChannelConfiguration is a property and not a method, so get rid of the "()".
Hope that helps,