473,326 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Destroying ActiveX controls

Hi

My VB.NET project has a Form which wraps a proprietary ActiveX control.
Efffectively the Form acts as a Class becuase the control must be placed on
a Form. The Form is not displayed by the application.

The application instantiates the Form, uses the control to connect to a
backend process disconnects, closes the Form and then performs a garbage
collection. However after four or five cycles of this the control stops
connecting to the backend process. I know the particular control to be
reliable becuase I've used it in VB6 projects without any problem. I
suspect after the Form and control is closed it's not being properly garbage
collected.

At present I've setup the following.

In the Form_Closing event I call the Control's disconnect method and then
the Control.Dispose method.

In the sub that instantiates the Form I've included the following:

If Not (lfrmCTI Is Nothing) Then
lfrmCTI.Close()
lfrmCTI.Dispose()

lfrmCTI = Nothing

GC.Collect()
GC.WaitForPendingFinalizers()

End If

Can someone tell me if this is the correct strategy to use to guarantee that
my Form and the control that it hosts will be detsroyed? Thanks.
--

----------------------------------------------------
This mailbox protected from junk email by MailFrontier Desktop
from MailFrontier, Inc. http://info.mailfrontier.com
Nov 21 '05 #1
4 1424
Peter,

It seems me much to much, when it is a form, it implements Idisposable, that
means that a close should be enough because that does all the work.

I hope this helps?

Cor

If Not (lfrmCTI Is Nothing) Then
lfrmCTI.Close()
lfrmCTI.Dispose()

lfrmCTI = Nothing

GC.Collect()
GC.WaitForPendingFinalizers()

End If

Nov 21 '05 #2
Cor

I was hoping the Close method would take care of the destruction of the Form
and any controls (ActiveX or otherwise) that it might contain. However, I'm
not so sure about this. I'd appreciate someone telling me whether a call to
Form.Close followed by a GC.Collect is enough.

Peter,

--
----------------------------------------------------
This mailbox protected from junk email by MailFrontier Desktop
from MailFrontier, Inc. http://info.mailfrontier.com

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ub**************@tk2msftngp13.phx.gbl...
Peter,

It seems me much to much, when it is a form, it implements Idisposable, that means that a close should be enough because that does all the work.

I hope this helps?

Cor

If Not (lfrmCTI Is Nothing) Then
lfrmCTI.Close()
lfrmCTI.Dispose()

lfrmCTI = Nothing

GC.Collect()
GC.WaitForPendingFinalizers()

End If


Nov 21 '05 #3
Peter,

Calling the GC has nothing to do with the destruction.
The GC is to help cleaning up the managed heap.

When you will search this newsgroup or other newsgroups mostly told as
useless.

However there are people who want that there is almost 50% of memory not
used in there computer, those are often calling the GC.

To get more information see this.

http://msdn.microsoft.com/architectu...l/scalenet.asp

This is a very large document. When you read about dispose, think than that
is about classes which do not implement Idisposable. (There will be a new
article about that in future).

Cor
Nov 21 '05 #4
On Fri, 13 Aug 2004 17:41:23 +1200, Peter Merwood wrote:
Can someone tell me if this is the correct strategy to use to guarantee that
my Form and the control that it hosts will be detsroyed? Thanks.


I don't know if it will solve your problem, but take a look at the
Marshal.ReleaseCOMObject method. I believe that you need to call this to
release the COM object.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fie Fie Niles | last post by:
This one XP machine (with IE 6) is having a problem viewing any ActiveX controls (created on VB6) on the Internet Explorer browser. I put the same ActiveX control in a VB program, and when I run...
12
by: A.M. | last post by:
Hi at all, how can I do to insert into a HTML page a file .txt stored in the same directory of the server where is the html file that must display the text file.txt? Thank you very much P.Pietro
0
by: Ike | last post by:
I have an Activex Control created in VB6, which, displays no problem on any machine I have, but, on some machines of others, it does not. All machines are running either XP or Windows 2000, and all...
7
by: Jarod_24 | last post by:
I just downloaded a activex control that was written in C# and tried to view it on my PDA's Internet Explorer. At my regular PC it displayed just fine, but nothing showed up on the pda. Do...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.