Home All Groups Group Topic Archive Search About

activeX doesn't dispose

Author
31 Mar 2005 11:43 AM
Peter Proost
Hi group,

Here at work they've got an activeX control which is used on a usercontrol,
and this usercontrol is one of the standard controls in the framework, so
this user controls get's used a lot on other usercontrols or windows forms.
But the problem is the activex control doesn't get disposed. (profiled the
app with scitech .net memory profiler 2.5) I added this code to disposing
event of the base usercontrol (the one in the framework which contains the
activeX):

'Grid is the name of the activeX control
'Toegevoeg door Peter 31/03/2005
If Not Grid Is Nothing Then
     Grid.Dispose()
End If
'einde toevoeging

but that doesn't help, I also tried it in the usercontrol's finalize method
but also no success. But if I create a sub in the usercontrol:

Public sub MyDispose
    If Not Grid Is Nothing Then
     Grid.Dispose()
    End If
End sub

and then in the form's closing event of the form that hosts the usercontrol
call

myusercontrol.Mydispose

the activex control get's disposed and releases it's memory.

But now my question is isn't there a way so I can dispose the activeX
control on the usercontrol from within the user control without the extra
sub.

Greetz Peter

Author
31 Mar 2005 11:53 AM
Crouchie1998
Use Garbage Collection (GC)
Author
31 Mar 2005 12:04 PM
Peter Proost
Hi,

thnx for the answer but I've always read/heard that you shouldn't use
gc.collect, except for in some special cases, is this one of them? Because
the form containing the usercontrol get's opened and closed a lot so
gc.collect would get executed a lot and doesn't this tend to mess up the gc?
Or have I miss understand you?

Greetz Peter

Show quoteHide quote
"Crouchie1998" <crouchie1***@discussions.microsoft.com> schreef in bericht
news:Ot#2yheNFHA.1176@TK2MSFTNGP15.phx.gbl...
> Use Garbage Collection (GC)
>
>
Author
31 Mar 2005 12:11 PM
Cor Ligthert
Peter,

I have no answer, however maybe you can find it on this page. At the bottom.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemidisposableclasstopic.asp

I hope this helps,

Cor
Author
31 Mar 2005 12:36 PM
Peter Proost
Hi Cor,

thanks for the link

Greetz Peter

"Cor Ligthert" <notmyfirstn***@planet.nl> schreef in bericht
news:#jXJLreNFHA.3420@tk2msftngp13.phx.gbl...
> Peter,
>
> I have no answer, however maybe you can find it on this page. At the
bottom.
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemidisposableclasstopic.asp
Show quoteHide quote
>
> I hope this helps,
>
> Cor
>
>
Author
31 Mar 2005 1:09 PM
Peter Proost
But I forget to mention, it was  interesting but it didn't help me out :-)
so I'm still puzzling

Greetz Peter

Show quoteHide quote
"Peter Proost" <pproost@nospam.hotmail.com> schreef in bericht
news:eUz8y5eNFHA.3328@TK2MSFTNGP14.phx.gbl...
> Hi Cor,
>
> thanks for the link
>
> Greetz Peter
>
> "Cor Ligthert" <notmyfirstn***@planet.nl> schreef in bericht
> news:#jXJLreNFHA.3420@tk2msftngp13.phx.gbl...
> > Peter,
> >
> > I have no answer, however maybe you can find it on this page. At the
> bottom.
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
Show quoteHide quote
> frlrfsystemidisposableclasstopic.asp
> >
> > I hope this helps,
> >
> > Cor
> >
> >
>
>
Author
31 Mar 2005 2:05 PM
Chris Dunaway
Try something like this:

Imports System.Runtime.InteropServices

Marshal.ReleaseComObject(Grid)

Does that help?
Author
31 Mar 2005 2:38 PM
Peter Proost
Hi thanks for the tip and I'll try that but I'm not even sure anymore if it
has to do with the Grid, because if I test it in a test app with the same
activex on a usercontrol and that usercontrol on yet another usercontrol and
that one on a form there's no problem, so I think that it's some bad coding
in some of our classes that causes the whole usercontrol not to be released.
So that's going to be some more puzzling...

Greetz Peter

Show quoteHide quote
"Chris Dunaway" <dunaw***@gmail.com> schreef in bericht
news:1112277900.299731.197290@z14g2000cwz.googlegroups.com...
> Try something like this:
>
> Imports System.Runtime.InteropServices
>
> Marshal.ReleaseComObject(Grid)
>
> Does that help?
>