04-10-2008 08:03 AM
We're in the process of upgrading our sequences from 3.5 to
4.0 and for the most part, everything is seamless. However, there is one situation I’ve found
that throws a RTE in 4.0 but works fine in 3.5.
When calling SetPropertyObject on an object reference, the following
error is thrown:
Parameter 'newValue': Expected Container, found Object Reference.
-17308; Specified value does not have the expected type.
Attached is a sequence snippet illustrating this behavior. The last step should assign the variable in Parameters with the name in TempStr (“Fred” in this example) to the first element in the TraceObjRefs array (an array of object references).
What is really confounding is that this works as expected in 3.5. Any insight as to what changed or what’s the best way to work around this?
04-10-2008 12:42 PM
I got rid of the error if I change Locals.TraceObjRefs to an array of Containers instead of an array of Object References. Not sure if that's the correct behavior but I don't get the error any more.
Cheers,
04-11-2008 07:01 AM
04-11-2008 01:23 PM
05-17-2012 09:09 AM
We are seeing something similar in TS 4.1.
We have a container with subproperties which are also containers (of the same type actually). Technically, this is an array, we are using the container to be able to address by name. When I extract one of the sub-properties either by GetPropertyObject or by GetNthSubproperty and then try to assign it to a container of the same type, I get the error "Expected container, found object reference".
I attached a sequence with some experiments, using the NI_Limits type and found a solution: the Evaluate method seems to actually copy the values from the source container to the target; but only when it is not called as "PropertyObject.Evaluate()" but stand alone.
But I did not quite understand the mechanics of the aliases. In the sequence, I create an alias, as indicated in the previous posts. Then I can apparently not change that alias again. I used the "Data" member in the NI_Limits container to differentiate between the individual containers.
After the second SetPropertyObject, the value stays the same as before. But when I then change the value in one of the source objects, the other changes with it.
So I am not quite clear what an alias actually is and what its effects are.
Regards
Peter
05-18-2012 09:50 AM
I'm confused, is your question about aliases or the error you are getting? Does the sequence illustrate the error, or the alias problem (it looks like the later)? If you want help with the error, a sequence which reproduces the error would be most helpful.
For aliases, an issue you might be hitting is that when you want to replace or directly access the alias (i.e. using SetPropertyObject), you need to use PropOption_ReferToAlias. So, for example, if you have a call to SetPropertyObject that you want to use to create a new alias that replaces the previous one that is there, you need to use both the PropOption_ReferToAlias and the PropOption_NotOwning options as follows:
Locals.ThisLimit.SetPropertyObject("", PropOption_ReferToAlias | PropOption_NotOwning, Locals.LimitRef)
Hope this helps,
-Doug