By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,314 Members | 2,155 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,314 IT Pros & Developers. It's quick & easy.

activeX doesn't dispose

P: n/a
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


Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Use Garbage Collection (GC)
Nov 21 '05 #2

P: n/a
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

"Crouchie1998" <cr**********@discussions.microsoft.com> schreef in bericht
news:Ot**************@TK2MSFTNGP15.phx.gbl...
Use Garbage Collection (GC)

Nov 21 '05 #3

P: n/a
Peter,

I have no answer, however maybe you can find it on this page. At the bottom.
http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
Nov 21 '05 #4

P: n/a
Hi Cor,

thanks for the link

Greetz Peter

"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:#j**************@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/de...us/cpref/html/
frlrfsystemidisposableclasstopic.asp
I hope this helps,

Cor

Nov 21 '05 #5

P: n/a
But I forget to mention, it was interesting but it didn't help me out :-)
so I'm still puzzling

Greetz Peter

"Peter Proost" <pp*****@nospam.hotmail.com> schreef in bericht
news:eU**************@TK2MSFTNGP14.phx.gbl...
Hi Cor,

thanks for the link

Greetz Peter

"Cor Ligthert" <no************@planet.nl> schreef in bericht
news:#j**************@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/de...us/cpref/html/ frlrfsystemidisposableclasstopic.asp

I hope this helps,

Cor


Nov 21 '05 #6

P: n/a
Try something like this:

Imports System.Runtime.InteropServices

Marshal.ReleaseComObject(Grid)

Does that help?

Nov 21 '05 #7

P: n/a
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

"Chris Dunaway" <du******@gmail.com> schreef in bericht
news:11**********************@z14g2000cwz.googlegr oups.com...
Try something like this:

Imports System.Runtime.InteropServices

Marshal.ReleaseComObject(Grid)

Does that help?

Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.