Out of interest why doesn't the interop layer, which is generated by VS or
tlbimp, use the Disposable pattern on the generated wrapper objects? This
implementation could then call Marshal.ReleaseComObject(this) to release
the underlying COM reference.

It would seem an ideal place to use this but perhaps I�m missing something
oblivious?

Jeremy


On Wed, 24 Mar 2004 17:35:58 +0530, Harish Jayaram
<[EMAIL PROTECTED]> wrote:

>If your class uses external resources but will not be used on a design
>surface,
>implement System.IDisposable, or derive from a class that
>directly or indirectly implements IDisposable.
>
>-----Original Message-----
>From: Moderated discussion of advanced .NET topics.
>[mailto:[EMAIL PROTECTED] Behalf Of Brian Weeres
>Sent: Wednesday, March 24, 2004 1:09 AM
>To: [EMAIL PROTECTED]
>Subject: Re: [ADVANCED-DOTNET] COM Interop and freeing references
>
>
>How about trying
>
>System.Runtime.InteropServices.Marshal.ReleaseComObject(myobject);
>
>-----Original Message-----
>From: Pandha Permjeet, Slough [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, March 23, 2004 11:44 AM
>To: [EMAIL PROTECTED]
>Subject: [ADVANCED-DOTNET] COM Interop and freeing references
>
>Hi,
>
>I have a .net app that uses a legacy COM Server component built as a VB6
>ActiveX Exe.
>
>I have added a reference to it using Visual Studio 2003 References menus
>and can use it perfectly well from my C# app.
>
>When the component is used, Windows runs it in a separate process. If
>you're using this in a VB app then you can simply free the reference by
>doing a "Set myref = null" and the process automatically disappears.
>
>The problem is how can I achieve the same effect in .Net/C#. The
>component is designed to be activated and released many times during the
>lifetime of an application, if the reference cannot be freed then you
>will have many of these processes running. Even if the reference to the
>component goes out of scope or is set to null it does not release the
>process. I would think that it would be released if the reference is
>garbage collected but it is not possible to directly invoke a collection
>(I've tried GC.Collect() with no effect).
>
>Any suggestions?
>Thanks
>Permjeet Pandha
>
>
>
>
>Scanned for viruses by MessageLabs. The integrity and security of this
>message cannot be guaranteed. This email is intended for the named
>recipient only, and may contain confidential information and proprietary
>material. Any unauthorised use or disclosure is prohibited.
>
>===================================
>This list is hosted by DevelopMentor(r)  http://www.develop.com Some
>.NET courses you may be interested in:
>
>NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
>http://www.develop.com/courses/gaspdotnetls
>
>View archives and manage your subscription(s) at
>http://discuss.develop.com
>
>===================================
>This list is hosted by DevelopMentor(r)  http://www.develop.com
>Some .NET courses you may be interested in:
>
>NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
>http://www.develop.com/courses/gaspdotnetls
>
>View archives and manage your subscription(s) at
>http://discuss.develop.com
>
>===================================
>This list is hosted by DevelopMentor�  http://www.develop.com
>Some .NET courses you may be interested in:
>
>NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
>http://www.develop.com/courses/gaspdotnetls
>
>View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to