473,396 Members | 1,827 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,396 software developers and data experts.

Force termination of COM object?

I'm developing a wrapper around a series of VB6 plugins that I now want to
be able to run in my VB.NET application.

Everything is working fine, except I can't find a way to get the
Class_Terminate from the VB6 classes to fire when I've finished with the
objects.

In VB6, these obviously fire when the last reference to the object is set to
Nothing. In .NET, this doesn't happen until I close my application (or,
presumably, when the garbage collector next runs).

Is there any way that I can force the VB6 classes to terminate? Some of them
have clean-up code in their Terminate events, and without running this I'm
worried that I may end up leaving resources locked. I have a Dispose method
in my .NET wrapper class so I have a point in code at which I could trigger
the termination, but I can't find a way to make it happen.

My thanks in advance,

--

(O) e n o n e
Nov 21 '05 #1
2 1631
Have a look at System.Runtime.InteropServices.Marshal.ReleaseComO bject.

Hope this helps,

Nick Hall
"Oenone" <oe****@nowhere.com> wrote in message
news:AD******************@newsfe1-win.ntli.net...
I'm developing a wrapper around a series of VB6 plugins that I now want to
be able to run in my VB.NET application.

Everything is working fine, except I can't find a way to get the
Class_Terminate from the VB6 classes to fire when I've finished with the
objects.

In VB6, these obviously fire when the last reference to the object is set
to
Nothing. In .NET, this doesn't happen until I close my application (or,
presumably, when the garbage collector next runs).

Is there any way that I can force the VB6 classes to terminate? Some of
them
have clean-up code in their Terminate events, and without running this I'm
worried that I may end up leaving resources locked. I have a Dispose
method
in my .NET wrapper class so I have a point in code at which I could
trigger
the termination, but I can't find a way to make it happen.

My thanks in advance,

--

(O) e n o n e

Nov 21 '05 #2
Nick Hall wrote:
Have a look at
System.Runtime.InteropServices.Marshal.ReleaseComO bject.


Ah, that's absolutely perfect, thank you very much.

--

(O) e n o n e
Nov 21 '05 #3

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

Similar topics

2
by: John Pote | last post by:
Running my programme in Python 2.3.4 I received the following msg in the consol :- (Pent III running W2K prof) """ Exception in Tkinter callback Traceback (most recent call last): File...
2
by: Jim McGrail | last post by:
Background: I am investigating a problem involving a windows .NET application that is being developed in C# with Visual Studio 2003. It is a multi-threaded application that uses MSMQ to...
2
by: ice88 | last post by:
I would like to execute some code when a thread terminates, in the context of that thread - I guess similar to an ExitThread handler - is it possible in a C# .NET application? I can see a way to...
5
by: John Smith | last post by:
Lets say I was given a Char array as: Dim Arr(size) As Char and this array holds a string which ends with a C-Style zero termination. I want to make this into a String object and cut it off at...
0
by: Sir Spamallot | last post by:
Hi there, Previously when handling the termination of threads I had just called the abort method and caught it in a try catch block in the thread callback. After recently learning that this was...
8
by: Henning M | last post by:
Hi, I'm trying to use stringbuilder to collect a list of strings. (as suggested by Claes Bergefall) Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" (ByVal pszFilter As String,...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
9
by: ehabaziz2001 | last post by:
I am facing that error message with no idea WHY the reason ? "Abnormal program termination" E:\programs\c_lang\iti01\tc201\ch06\ownarr01o01 Enter a number : 25 More numbers (y/n)? y...
0
by: vsankar9 | last post by:
It's an Service Contracts From CRM. I need termination amount for who's the customer is terminated . End date - 15-DEC-2007 Termination as of date - 15-MAR-2007 Rate - 1000 (monthly rate ) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.