The information in this article applies to:
SYMPTOMSThe following error message appears when using an assign method to store object references in a property and then trying to access properties of that object through the property:
CAUSEThe assign method fires twice when assigning an object reference to a property. The first time it fires, it sets the value of the property containing the object reference to NULL and then it runs again and assigns the property the object reference. RESOLUTION
In the assign method, check to see if the new value is not NULL before assigning it to the property.
MORE INFORMATIONSteps to Reproduce BehaviorThe code in the steps below defines a class named Test that has two properties, obj and prevobj. The obj property has an assign method on it. The assign method takes the value in the obj property and assigns it to prevobj before the new value of obj is assigned.The code in the program creates an object reference to the Test class and then instantiates an instance of a class based on the custom base class and assigns this object reference to the obj property. It does this three times. When the reference to the custom class is assigned to the obj property, the assign method fires. The code outputs with ? commands to the Visual FoxPro desktop the values in the obj and prevobj properties at various times. Note that the ? command in the assign method fires twice the second and third times the new object reference to the custom class is assigned to the obj property. The error message appears the third time when oTest.prevobj is not checked to see if it is NULL before accessing the oTest.prevobj.name property.
The assign method only fires once when assigning other data types to a property. Code to demonstrate this is not included in this article. Additional query words: kbDSE
Keywords : kbOOP kbVFp600 kbGrpFox kbDSupport kbCodeSnippet |
Last Reviewed: November 17, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |