Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Releasing a reference to VFP
Message
 
À
23/06/2009 14:53:42
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Application:
Desktop
Divers
Thread ID:
01407831
Message ID:
01407872
Vues:
38
>>>Hi All,
>>>
>>>I am trying to build a COM object to notify a parent application (VFP) when a file changes. When initialize tyhe COM I am passing a object reference to a VFP form to it. It uses this refernce to call a method to imform the form that a file has changed. Up to this point all is work great. The problem comes when I try to close the VFP form. In the destroy event of the form I am calling a method in COM to release the object. This in turn breaks the object reference to VFP. But it does not appear to be release the reference. Both the form and the COM remain in memory. Form is still visible and the COM is still loaded. After search the web over the last few days, I found this snipit of code. But it reports that the oObj does not reference an object and does not free.
>>>
>>>
>>>Try
>>>       Do
>>>            If Marshal.ReleaseComObject(oObj) <= 0 Then Exit Do
>>>            oObj = Nothing
>>>       Loop
>>>Catch ex As System.Exception
>>>       MsgBox("ERROR - " & ex.Message & " [ShutDown]")
>>>End Try
>>>
>>>
>>>What can I do to successfully release the reference?
>>
>>I do not know whether it will help in your case; I experienced something similar having hanging Excel object and the call like below did not release it:
>>
>> System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
>>
>>
>>
>>However the identical second call did it. Do not know why.
>>
>>System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
>>System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
>>
>
>Probably the same reason that the example I found has the Marshal.ReleaseComObject in a look. But it is worth a try.
>
>I am beginnig to think it is not how I am attempt to release it, but how I am assign the local .NET object reference back to VFP. As property of my COM class I am declaring an System.Object.
>
>
>  Public oObj as System.Object
>
>  Public Sub SetPath( ByVal toObj As Object, ....
>
>           oObj = toObj
>
>           ....
>
>
>Is this the correct way to assign the local property the reference to the VFP form?

Cannot tell you for sure.
What I can tell in addition is that I also needed to set variable to nothing after Marshal calls
oExcel= Nothing
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform