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 / March 2005

Tip: Looking for answers? Try searching our database.

Interop COM in C# - can't get the object released

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alan - 25 Mar 2005 20:09 GMT
I am trying to develop an ATL COM object together with a C# web
application that will host it. I am following the COM Interop Part 1: C#
Client Tutorial, Example 2, The C# Code Approach from the April 2004
MSDN library exactly. But the client will not release the COM object.

The COM object is being run in its own solution and under a separate
instance of Visual Studio .NET 2003. At this point the object consists
only of the constructor, FinalConstruct, and FinalRelease. No methods or
properties have been implemented on the interface.

The C# client is the corresponding code according to the tutorial and is
in the code-behind of a .NET web form. No methods or properties on the
interface.

However, after I have run the simple

MyCOMTypeLib.MyCOMManager manager = new MyCOMTypeLib.MyCOMManager()

command and have exited either the debugger or the browser independent
of Visual Studio. A reference remains on MyCOM.dll. The dll cannot be
rebuilt and it cannot be deleted. The only way I have found to clear the
reference is to reboot the computer.

Is there a way for force the DLL to be unloaded? When programming ASP,
this could be done by unloading the application with the IIS manager.

Better yet, why is this reference remaining contrary to documentation?
Robin Tucker - 29 Mar 2005 15:39 GMT
How are you releasing the COM components you use (assuming MyCOMManager is a
com component)?

If you have a reference to an interface from COM, you need to
Marshal.ReleaseCOMObject on the instance before you exit.

>I am trying to develop an ATL COM object together with a C# web
> application that will host it. I am following the COM Interop Part 1: C#
[quoted text clipped - 23 lines]
>
> Better yet, why is this reference remaining contrary to documentation?
Alan - 29 Mar 2005 15:59 GMT
Robin,

Thank you for responding.

At this point, the only operation with the COM component is to create it
with 'new'.  No interfaces have been called.  I tried using
Marshal.ReleaseCOMObject without success.

Alan

> How are you releasing the COM components you use (assuming MyCOMManager is a
> com component)?
[quoted text clipped - 29 lines]
> >
> > Better yet, why is this reference remaining contrary to documentation?
Robin Tucker - 29 Mar 2005 16:47 GMT
Well, in my experience there is something else to consider.  Firstly, if the
COM object is "out of process", it will stay in memory unless it is
explicitly "exited".  I know this only from using Microsoft Word interop,
where even if you release all references to the COM object, the image stays
in task manager, so you execute the m_WordApplication.Quit command and it
goes.  Perhaps you are out of process and hence also need to implement a
quit command on your object?

> Robin,
>
[quoted text clipped - 44 lines]
>> >
>> > Better yet, why is this reference remaining contrary to documentation?
Alan - 29 Mar 2005 17:23 GMT
Robin,

At this point the COM object does nothing.   It doesn't even have variables
ore interface members yet.  Before developing it, I want to make sure I know
how to do the interop correctly, starting from creating and releasing it.

Actually, I think that the problem is in ASPNET.  I am using a web
application to develop and debug the COM object.  When using ASP, one simply
unloads the application after each debugging run.  I don't know how to unload
ASPNET other than to stop and restart w3svc.

Alan

> Well, in my experience there is something else to consider.  Firstly, if the
> COM object is "out of process", it will stay in memory unless it is
[quoted text clipped - 52 lines]
> >> >
> >> > Better yet, why is this reference remaining contrary to documentation?

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.