Solved

Marshal.ReleaseComObject   use in VB.Net

Posted on 2009-04-08
2
893 Views
Last Modified: 2012-05-06
I am trying to use this:
While xxxxxx <> 0
    System.Runtime.InteropServices.Marshal.ReleaseComObject(xxxxxx)

I am trying to execute this statement just before I exit a COM class.  Is xxxxxx the Com class name?  Can I release it when I am still in it?

Can you provide a while loop where xxxxxx = the com clas name and is the only COM component

 

0
Comment
Question by:garyinmiami2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 24100646
Unless I am missing something, xxxxxx is a variable holding a reference to your COM object. When in your While loop, you are not "in" the COM. Your COM object exists regardless of your loop. Your loop is saying "keep trying to release (ReleaseComObject) this object until the variable xxxxxx points to 0 and not to a COM object."
0
 

Author Comment

by:garyinmiami2003
ID: 24102156
I would like to clarify a little

Suppose there is a COM Class in a class library and it has been installed on your pc.  The method called in the class begins

Public Function Broker(ByVal extensionData As thirdparty..IFaExtensionData)

(    all kinds of code)


System.Runtime.InteropServices.Marshal.ReleaseComObject(extensionData)

end Function

My question is:  Is this necessary?  Is this the correct way to use it, if it is necessary?






                                       
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question