Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning a collection from a COM
Message
 
 
To
12/08/2004 08:01:12
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00932180
Message ID:
00932989
Views:
19
It doesn't crash for me. VFP8SP1 under Win2KSP4Pro.

>I tested your code and it work. But this code will crash:
DEFINE Class pm As session OlePublic   && Compile as a COM (MyDLL.DLL)
>PROCEDURE getListeTables ()
>   oTables = CREATEOBJECT ("Collection")
>
>   FOR i=1 TO ADIR (laList, "h:\temp\*.DBF")
>      oTables.Add(laList[i,1])
>   ENDFOR
>
>   RETURN oTables
>ENDPROC	
>ENDDEFINE
>
>...
>
>DEFINE Class pm2 As session OlePublic   && Compile as a COM (MyDLL2.DLL)
>PROCEDURE getListeTables ()
>   oTables = CREATEOBJECT ("MyDLL.PM")
>   oListTables = oTables.getListeTables ()
>   oTables = NULL   && This may cause the crash
>   RETURN oListTables
>ENDPROC	
>ENDDEFINE
>
>...
>
>o = CREATEOBJECT("mydll2.pm2")
>oTables = o.getListeTables()
>? oTables.Count   && Crash here
>
>FOR EACH lcTable IN oTables
>   ? (lcTable)
>ENDFOR
I didn't mention this before because I didn't think it will have an impact, but now I think I know why it crash. The DLL that create the collection is killed before returning the collection to the parent. My guess is that it kill also the collection and when I'm trying to access it, VFP goes berzerk.
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform