PC Review


Reply
Thread Tools Rate Thread

activeX doesn't dispose

 
 
Peter Proost
Guest
Posts: n/a
 
      31st Mar 2005
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




 
Reply With Quote
 
 
 
 
Crouchie1998
Guest
Posts: n/a
 
      31st Mar 2005
Use Garbage Collection (GC)


 
Reply With Quote
 
Peter Proost
Guest
Posts: n/a
 
      31st Mar 2005
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" <(E-Mail Removed)> schreef in bericht
news:Ot#(E-Mail Removed)...
> Use Garbage Collection (GC)
>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      31st Mar 2005
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


 
Reply With Quote
 
Peter Proost
Guest
Posts: n/a
 
      31st Mar 2005
Hi Cor,

thanks for the link

Greetz Peter

"Cor Ligthert" <(E-Mail Removed)> schreef in bericht
news:#(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Peter Proost
Guest
Posts: n/a
 
      31st Mar 2005
But I forget to mention, it was interesting but it didn't help me out :-)
so I'm still puzzling

Greetz Peter

"Peter Proost" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> Hi Cor,
>
> thanks for the link
>
> Greetz Peter
>
> "Cor Ligthert" <(E-Mail Removed)> schreef in bericht
> news:#(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Chris Dunaway
Guest
Posts: n/a
 
      31st Mar 2005
Try something like this:

Imports System.Runtime.InteropServices

Marshal.ReleaseComObject(Grid)

Does that help?

 
Reply With Quote
 
Peter Proost
Guest
Posts: n/a
 
      31st Mar 2005
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" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> Try something like this:
>
> Imports System.Runtime.InteropServices
>
> Marshal.ReleaseComObject(Grid)
>
> Does that help?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dispose which doesn't "dispose" Peter Microsoft C# .NET 5 11th Sep 2008 09:25 PM
Hang in Dispose with ActiveX control Jeff Microsoft Dot NET 0 4th May 2006 08:43 PM
Dispose a Form with an ActiveX control(AxHost). rdascalescu@gmail.com Microsoft Dot NET Framework Forms 0 8th Jun 2005 08:39 PM
Unable to dispose old ActiveX from a Form Romy Microsoft Dot NET Framework Forms 0 7th Jun 2005 05:29 PM
Dispose doesn't free memory Memory Issues Microsoft C# .NET 6 11th Nov 2003 10:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:13 PM.