Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / November 2005

Tip: Looking for answers? Try searching our database.

How to dispose C# object created via VB6 COM component interop?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
natety - 21 Sep 2005 16:46 GMT
I am having problems getting a C# component to release itself fro
memeory when calling it from a VB6 COM component via an interop.  Thi
is what I am doing:

VB6 COD

Dim oInterOPConnect As Object

Set oInterOPConnect = oContext.CreateInstance("namespace.Interop")
oInterOPConnect.Save(szXMLString)
oInterOPConnect.Dispose
Set oInterOPConnect = Nothing

The C# component inherits from iDisposable so I added th
"oInterOPConnect.Dispose" part to the VB6 code, but that did not d
anything for me

--
natet
Mattias Sjögren - 21 Sep 2005 19:35 GMT
>I am having problems getting a C# component to release itself from
>memeory when calling it from a VB6 COM component via an interop.

Release in what way? The object will eventually be garbage collected
once you release all references to the CCW. The assembly will stay in
memory until the appdomain is unloaded.

Mattias

Signature

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

natety - 21 Sep 2005 20:01 GMT
Release from memory.   As it currently stands, each call to the C
object creates another object in memory.   I have over a 1000 object
in memory right now and it is only going up.   The only way to releas
the objects from memory is to shut down and recycle the package

--
natet
Uday Takbhate [MSFT] - 22 Sep 2005 03:42 GMT
The issue seems to be related with the known issue with .Net framework SP1

http://support.microsoft.com/?id=317109
Office application does not quit after automation from Visual Studio .NET
client

http://support.microsoft.com/?id=884541
FIX: You cannot use the IDispatch interface on the AppDomain object after
you install the .NET Framework 1.1 SP1
KB article 884541 which mentions about a hot-fix for the similar issue.

Please note that this hot-fix is not re-distributable.

For more information on AppDomains, please refer to the article
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/htm
l/csharp05162002.asp

Regards,
Uday Takbhate [MSFT]
Microsoft Developer Support
--------------------
>NNTP-Posting-Date: Wed, 21 Sep 2005 14:49:33 -0500
>Newsgroups: microsoft.public.dotnet.framework.interop
>Subject: Re: How to dispose C# object created via VB6 COM component
interop?
>Date: Wed, 21 Sep 2005 14:01:24 -0500
>Organization: MS Usenet
>User-Agent: vBulletin USENET gateway
>X-Newsreader: vBulletin USENET gateway
>X-Originating-IP: 205.142.252.17
<OJ2yKutvFHA.3864@TK2MSFTNGP12.phx.gbl>
>Lines: 1
>X-Trace:
sv3-OoqvXvAQ2rldSawH1GhW2gFVfIecB9LdTOqPx1jszLeCrrPPgWCPOYNMtiXyHTRUWJd3wIVq
kuZdg2H!J8RC+vLd6joBrsWDD4dJrFWSeeC4uCIek1uKZaEXHLkgSehQ1YoUAhaz
>X-Complaints-To: abuse@giganews.com
>X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
>X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
>X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
>X-Postfilter: 1.3.32
>Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.gigan
ews.com!local01.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
>Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework.interop:9749
>X-Tomcat-NG: microsoft.public.dotnet.framework.interop

Release from memory.   As it currently stands, each call to the C#
object creates another object in memory.   I have over a 1000 objects
in memory right now and it is only going up.   The only way to release
the objects from memory is to shut down and recycle the package.

Signature

natety

Willy Denoyette [MVP] - 26 Sep 2005 09:31 GMT
Sorry but I don't see how this might relate to the OP's problem, the OP
isn't using AppDomain objects.

Willy.

> The issue seems to be related with the known issue with .Net framework SP1
>
[quoted text clipped - 48 lines]
> in memory right now and it is only going up.   The only way to release
> the objects from memory is to shut down and recycle the package.
Willy Denoyette [MVP] - 26 Sep 2005 09:34 GMT
Please post your .NET code, and please be more explicit, what do you mean by
"each call to the C# object", do you mean each "method" call or do you mean
each object creation call?

Willy.

> Release from memory.   As it currently stands, each call to the C#
> object creates another object in memory.   I have over a 1000 objects
> in memory right now and it is only going up.   The only way to release
> the objects from memory is to shut down and recycle the package.
H Wu - 08 Nov 2005 15:46 GMT
I 'm also having the same issue as natety, where memory keep build up until
our VB application is totally shutdown. Is there way we can unload the all
those objects created in our Interop code? Read something about AppDomain but
I'm having problem with how load a NET dll. Any suggestion would be great
help.

> Please post your .NET code, and please be more explicit, what do you mean by
> "each call to the C# object", do you mean each "method" call or do you mean
[quoted text clipped - 6 lines]
> > in memory right now and it is only going up.   The only way to release
> > the objects from memory is to shut down and recycle the package.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.