Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning a collection from a COM
Message
 
 
À
12/08/2004 08:01:12
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00932180
Message ID:
00932989
Vues:
17
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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform