473,594 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COM interop - disposing COM objects

Hi folks,
When we instantiate COM objects from our .NET code and use
them, when we no longer need the COM objects do we have to
dispose of them explicitly? If so, how?
or do the COM objects also go out of scope and get picked
up by the garbage collector? Thanks a lot for your replies.
Nov 15 '05 #1
1 2011
When we instantiate COM objects from our .NET code and use
them, when we no longer need the COM objects do we have to
dispose of them explicitly? If so, how?


The garbage collector will handle the cleanup eventually, yes. You can
use Marshal.Release ComObject if you don't want to wait for the GC.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2

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

Similar topics

15
3726
by: Chris Capel | last post by:
I've heard a lot of talk on the forum about memory managment in .NET and disposing things, finalizing them, garbage collection, etc. My question is which managed types need to be disposed after being used, and for which is it OK to simply let the garbage collector do its work, without worrying about calling Dispose? Is there a general rule that most don't need to be explicitly disposed, with an exception here and there? Or the other way...
1
1989
by: Nadav | last post by:
Hi, Introduction *************** I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer, this layer manage the underlying COM Objects and upon request, provide a pointer to those objects to the 'API Consumer', following is an illustration of the system: API Consumer ( Native C++/C# ) || ******************************************* * ...
1
4875
by: Chris B. | last post by:
If anyone can figure out how to implement the following C++ function in C# using interop, I'd be very appreciative. I have not been successful in getting it to work correctly using interop (without using unsafe code) because of the pointer issues of the structure. Thanks, Chris //------------------------------------------------------------
7
1139
by: Mariusz | last post by:
Hello, I have question regarding disposing objects in aspx/cs pages. If I create some objects/Arrays/ListArrays in pageLoad do I have to dispose them (by assigning the null value for objects that doesn't have dispose method). If so then where should I do this? I need to use those objects in scripts in aspx page (they are created in cs PageLoad) - so I have to dispose them after they are not needed any more. Cheers Mariusz
4
5666
by: john | last post by:
I'm having some Interop problems. I really need someone's help on this, i'm running out of ideas. I have upgraded my Data access controls to the latest ver. Now then i have a form with these ref's: Interop.DAO,System,System.Data,System.Drawing,System.windo ws.forms,System.XML. all that's on this form is a button and when the button is clicked it opens up a fox pro database and gets the needed info/close. Now this works just fine on my
7
6364
by: Mark | last post by:
I am trying to take a working VB.NET program (the SHOW HTML program from the Halvorson book) and pass in parameter values which are used to build the URL that IE looks up. The original program works with a fixed URL, such as "http://www.microsoft.com". Interop.SHDocVw is part of the original program. However, when I bring in values from outside the program, the url string is built correctly, but the program crashes saying:
2
5008
by: Robert Bravery | last post by:
Hi all, Being new to C# and .net I often don't know how to use things. I have created an app that imports excel data, it works well, with methods to open excel, extract the data and close excel. Now a colege of mine suggested useinf the usingstatement, so that the office object is dispossed/destroyued correctly, saying that it prevents memoryleaks. Problem is I am having problems trying to achieve this, I keep getting the error: type...
11
2338
by: michelqa | last post by:
When executing some win32 messages in c# I get unexpected results. The following example is suppose to return the handle of an image in a button control of another application but it return a negative handle...is anybody know why it return an invalid handle like "-989523277" ?? IntPtr ImageHandle = Win32.SendMessage(Handle,BM_GETIMAGE,IntPtr.Zero,IntPtr.Zero); MessageBox.Show(ImageHandle.ToString());
29
2357
by: Jerry Spence1 | last post by:
I'm rather confused as to whether something should be disposed of, or not. What is the general rule? How can you be sure of doing the right thing? I've heard about disposing unmanaged resources but what is an unmanaged resource? Does everything need disposing? I've been using Webrequest, Webresponse, Streamreaders etc. How can I be sure of what needs disposing? Do these get automatically get disposed of at the end of the procedure...
0
7936
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8366
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6646
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5738
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3853
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1469
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.