472,791 Members | 1,097 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Excel.exe is in not releasing from the Process List

In my web application(C#) . I am adding one excel sheet and then save and
closing that excel file. In the finally bloack i gave

Marshal.ReleaseComObject(clsExcel);

But when i go and see in the TaskManager --Processes Tab its still having
that Excel.exe. If i opened more than one excel sheet and do these operations
then more than one Excel.exe is displaying in the list.

Please any one give me the solution for this issue.
Aug 26 '06 #1
2 2473

"B.N.Prabhu" <pr******@officetiger.comwrote in message
news:27**********************************@microsof t.com...
| In my web application(C#) . I am adding one excel sheet and then save and
| closing that excel file. In the finally bloack i gave
|
| Marshal.ReleaseComObject(clsExcel);
|
| But when i go and see in the TaskManager --Processes Tab its still
having
| that Excel.exe. If i opened more than one excel sheet and do these
operations
| then more than one Excel.exe is displaying in the list.
|
| Please any one give me the solution for this issue.

One solution is NOT to use Office applications in Web applications, read
this http://support.microsoft.com/default...b;en-us;257757 to know
why.

Willy.
Aug 26 '06 #2
B.N. Prabhu,

Well, you need to post more of your code in order for that to be
determined. However, it is more than likely that this is the result of you
not releasing all of the references to the objects that you are using.
Every object in Excel has a reference to the main Application, and you MUST
release all of those references when you use them.

The thing is, most people create references, and don't even know it.
Normally, they do this:

// Get a cell value. BTW, I dont expect this to compile, its to prove a
point.
object value = workbook.Worksheets.Item(1).Cells.Item(0, 0).Value;

The thing is, when you call Workbooks, you are exposing an object which
has a reference to application, but then it goes out of scope, and you have
to wait for a GC to release the reference. What you need to do is this:

// Again, won't compile, but you get the idea.
object worksheets = workbook.Worksheets;
object worksheet = worksheets.Item(1);
object cells = worksheets.Cells;
object cell = cells.Item(0, 0);
object value = cell.Value;

// Release everything.
Marshal.ReleaseComObject(cell);
Marshal.ReleaseComObject(cells);
Marshal.ReleaseComObject(worksheet);
Marshal.ReleaseComObject(worksheets)

This is what you have to do for pretty much every object reference in
Excel.

Of course, what you could do is assuming you have released all the
references (to the Runtime Callable Wrappers), you could just call
GC.Collect to force the release of the wrappers, which would force the
release of the COM object, and then your app should end as well.

BTW, Willy is correct in that you shouldn't really be using Excel in web
applications.

Hope his helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

;"B.N.Prabhu" <pr******@officetiger.comwrote in message
news:27**********************************@microsof t.com...
In my web application(C#) . I am adding one excel sheet and then save and
closing that excel file. In the finally bloack i gave

Marshal.ReleaseComObject(clsExcel);

But when i go and see in the TaskManager --Processes Tab its still
having
that Excel.exe. If i opened more than one excel sheet and do these
operations
then more than one Excel.exe is displaying in the list.

Please any one give me the solution for this issue.

Aug 26 '06 #3

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

Similar topics

3
by: Joseph | last post by:
Hello, I am developing a program that will read data from a couple of text files, process it, and then, populate data into specific cells in an Excel spreadsheet. Towards the end of the...
2
by: lasmit42 | last post by:
Guys I am writing a program which reads the first cell of many Excel spreadsheets and then takes some actions. The problem that I am experiencing is that each Excel instance I create persists...
11
by: Tim Marsden | last post by:
Hi, I have a routine which is call from a ASP.NET web form. This routine creates an excel application, opens a workbook , runs some code to update the workbook, saves it as HTML on the sever and...
10
by: Lars-Erik Aabech | last post by:
Hi! This issue have been discussed a lot, but I haven't found a solution that applies to ASP.NET. I have a library which does some operations on Excel documents, and it will be used in an...
18
by: lgbjr | last post by:
Hi All, I have a VB.NET app that, among other things, writes data to Excel. I am having trouble getting the Excel process to terminate after I quit Excel. I found an article related to this...
7
by: SteveS | last post by:
I'm attempting to close EXCEL from within my VB.NET application. Using the excel object library to write data to my spreadsheet is working fine but when I try to quit application object it does not...
13
by: chuckie_9497 | last post by:
hello all you gurus. I am struggling with releasing com objects. I have isolated the problem to the code below. Objects are released and the process ends until I use "int k = sheet.Count;" Then...
10
by: Hendri Adriaens | last post by:
Hi, I'm trying to automate the creation of an excel file via COM. I copied my code below. I read many articles about how to release the COM objects that I create. The code below runs just fine...
0
NeoPa
by: NeoPa | last post by:
Many of us have noticed that there are some very useful functions available to you when using Excel, but these same functions are not available, as standard, in Access. A particular issue I had...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{

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.