473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

cominterop excel and c#

Hi
in my app im working with excel using cominterop when fished my work with
excel i execute this code

oWB.Close(null,null,null);
oXL.Workbooks.Close();
oXL.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComO bject (oXL);
System.Runtime.InteropServices.Marshal.ReleaseComO bject (oSheet);
System.Runtime.InteropServices.Marshal.ReleaseComO bject (oWB);
oSheet=null;
oWB=null;
oXL = null;
GC.Collect();
but Excel.exe still remains in memory untill i unload my exe, any ideas?

Thanks
Nov 16 '05 #1
4 2180
Ariel,
but Excel.exe still remains in memory untill i unload my exe, any ideas?


There are still intermediate objects (such as the Workbooks
collection) that haven't been released, and they might keep Excel
running.

Mattias

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

In his code he's closed the workbooks, shut down Excel, released the
associated COM objects, and set them to null. So in what sense are there
any intermediate objects that haven't been released??

And in any event -- what would the solution be?

--Bob

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Ariel,
but Excel.exe still remains in memory untill i unload my exe, any ideas?


There are still intermediate objects (such as the Workbooks
collection) that haven't been released, and they might keep Excel
running.

Mattias

Nov 16 '05 #3
Thanks Mattias and Bob, i dont know whats happen, but affortunately, build
release mode and running the executable closes the excel completely, the
problem was when running in debug mode from the vs.net 2003 ide

"Bob Grommes" <bo*@bobgrommes.com> wrote in message
news:eG**************@TK2MSFTNGP09.phx.gbl...
But Mattias,

In his code he's closed the workbooks, shut down Excel, released the
associated COM objects, and set them to null. So in what sense are there
any intermediate objects that haven't been released??

And in any event -- what would the solution be?

--Bob

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Ariel,
but Excel.exe still remains in memory untill i unload my exe, any
ideas?
There are still intermediate objects (such as the Workbooks
collection) that haven't been released, and they might keep Excel
running.

Mattias


Nov 16 '05 #4
Bob,
In his code he's closed the workbooks,
Right, but not the workbook collection object returned here

oXL.Workbooks.Close();
^^^^^^^^^

To release that object you'd have to do

Excel.Workbooks wbs = oXL.Workbooks;
wbs.Close();
Marshal.ReleaseComObject(wbs);

And in any event -- what would the solution be?


Be really careful to release everything object you touch (which can
make the code really ugly) or force a garbage collection after you're
done with all the objects. Neither way is really good.

Mattias

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

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

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
2
by: me | last post by:
What is the downside of Cominterop? is it good practice? what does it do to memory? Thanks
3
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet...
6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
0
by: Mário Sobral | last post by:
Hi ! I have developed a .NET library that references another .NET library. MyLibrary -> OtherLibrary I then create a COMInterop wrapper assembly to use it from a VB6 project:
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
22
by: Howard Kaikow | last post by:
There's a significant problem in automating Excel from VB .NET. Reminds me of a problem I encountered almost 3 years ago that was caused by the Norton Auntie Virus Office plug-in. Can anybody...
1
by: info | last post by:
Hi I've an C# .NET 2.0 Windows Forms Application which is placed in an DLL. This DLL is instanciated from an non .NET enviroment via ComInterop. This works fine. but I need to put the wohle...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.