>Dragan,
>
>What's the last executable code line in the script?
In one version, it's "return oObj", in the other it's "toCaller.oRef=oObj". The object is verified to exist (in the debugger), but the next line of code that executes after that is in its .destroy().
To me it seems that VFP kills the temporary .fxp that it created for the script, and therefore the definition of the class in it, which causes the object to get destroyed.
If this can't be circumvented, well then I'll copy it out to a prg, compile it and run from that. I'll do the cleanup on my own - it'll be the caller's job to erase the .prg and .fxp when it unloads.