Dave,
Create the following class:
*-- Class: cusgfp (c:\program files\microsoft visual studio\vfp98\testgfp.vcx)
*-- ParentClass: custom
*-- BaseClass: custom
*-- Time Stamp: 08/27/99 08:47:11 AM
DEFINE CLASS cusgfp AS custom
cSetClassLib = ""
Name = "cusgfp"
PROCEDURE Init
This.cSetClassLib = SET("CLASSLIB")
SET CLASSLIB TO
ENDPROC
PROCEDURE Destroy
LOCAL lcSetClassLib
lcSetClassLib = This.cSetClassLib
SET CLASSLIB TO &lcSetClassLib
ENDPROC
ENDDEFINE
Now from the Command Window, type:
oCrash = NEWOBJECT("cusgfp", "c:\program files\microsoft visual studio\vfp98")
RELEASE oCrash
oCrash = NEWOBJECT("cusgfp", "c:\program files\microsoft visual studio\vfp98")
BLAMOThe Invalid Page Fault occurs when you instantiate the object the second time. This makes sense due to my understanding of an implicit SET CLASSLIB when using NEWOBJECT for object instantiation.
While one may say that someone would be insane to use a class like the one above, some objects instantiate other objects which instantiate other... and so on. I found this problem with my framework's application object which fires an environment object used to set/reset global SETS - including SET CLASSLIB.
>Please provide a code sample. Your steps below are confusing to me.
>
>Thanks,
>
>Dave
>
>>I have found a special case that is guaranteed to cause a VFP Invalid Page Fault and, therefore, should be avoided:
>>
>>- NEWOBJECT(
CLassName,
CLassLibrary) is used to instantiate an object and ;
>>
>>-
SET CLASSLIB TO is issued
before the instantiation of the object is complete and ;
>>
>>-
SET CLASSLIB TO ClassLibrary (same class library) is issued
after the instantiation of the object is complete and ;
>>
>>- The object is released and ;
>>
>>- NEWOBJECT(
CLassName,
CLassLibrary) is used to instantiate the object again,
THEN ;
>>
>>blamo -
VFP Invalid Page Fault every time.
- Jeff