Solution
When using a LabWindows/CVI code module with a valid SequenceContext, the correct approach is to retrieve Parameters.MainSequenceResult directly using TS_PropertyGetValIDispatch, otherwise this operation will result in the same error shown above. The example demonstrates how achieve this from a CVI code module that reads values from the TestStand Parameters.MainSequenceResult object reference.Equivalent TestStand expression:
ThisContext.AsPropertyObject.GetValInterface("Parameters.MainSequenceResult",0).AsPropertyObject.GetValNumber("Error.Code", 0)
In CVI, the TS_PropertyGetValIDispatch returns the object reference as a CAObjHandle, which can then be passed directly to other TestStand PropertyObject API functions such as TS_PropertyGetValNumber, TS_PropertyGetValString, and TS_PropertyGetValBoolean. The following code shows how to obtain that reference and call the TS_PropertyGetValNumber:
CAObjHandle mainSequenceResult = 0;
tsErrChk(TS_PropertyGetValIDispatch(seqContextCVI, &errorInfo, "Parameters.MainSequenceResult", 0, &mainSequenceResult));
tsErrChk(TS_PropertyGetValNumber(mainSequenceResult, &errorInfo, "Error.Code", TS_PropOption_NoOptions, &mainSeqErrorCode));