By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,672 Members | 1,628 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,672 IT Pros & Developers. It's quick & easy.

Excel.exe is in not releasing from the Process List

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a

"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.