473,405 Members | 2,282 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,405 software developers and data experts.

Excel STILL won't .Quit()

Jim
OK, now I'm really stumped. I have a ASP.NET w/ C# application that is
using Excel XP to do automation. Everything works just great, but Excel
stays resident in memory after I try to .Quit(). I have read all of the
other posts on this subject and implemented what's been suggested. For
example, I am doing the
System.Runtime.InteropServices.Marshal.ReleaseComO bject on every object that
I instantiate, including all ranges that I use, the workbook, etc., and
setting them to null. What is bizarre is that after recompiling, the first
time I run the page, Excel is not resident in memory, but each subsequent
time the page is run, a copy remains in memory. This is the code I'm using:

Microsoft.Office.Interop.Excel.Application xl = new
Microsoft.Office.Interop.Excel.ApplicationClass();

Microsoft.Office.Interop.Excel.Workbook wb = xl.Workbooks.Add(-4167);
//Generic template

//Don't bother doing anything for now

wb = wb.Close(true,"C:\test.xls",null);

xl.Quit();

System.Runtime.InteropServices.Marshal.ReleaseComO bject(wb);

System.Runtime.InteropServices.Marshal.ReleaseComO bject(xl);

wb = null;

xl = null;

Please help, this is the last thing and we're releasing Monday!

Thanks, Jim
Jul 21 '05 #1
2 5222
Jim
I've figured this out. I ended up writing API calls to kill the process.
Thanks
Jul 21 '05 #2
I think calling Marshal.ReleaseComObject() with the Excel instance will give
you what you want.

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://weblogs.asp.net/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
"Jim" <no**********@cogenix.com> wrote in message
news:uQ**************@TK2MSFTNGP11.phx.gbl...
OK, now I'm really stumped. I have a ASP.NET w/ C# application that is
using Excel XP to do automation. Everything works just great, but Excel
stays resident in memory after I try to .Quit(). I have read all of the
other posts on this subject and implemented what's been suggested. For
example, I am doing the
System.Runtime.InteropServices.Marshal.ReleaseComO bject on every object that I instantiate, including all ranges that I use, the workbook, etc., and
setting them to null. What is bizarre is that after recompiling, the first time I run the page, Excel is not resident in memory, but each subsequent
time the page is run, a copy remains in memory. This is the code I'm using:
Microsoft.Office.Interop.Excel.Application xl = new
Microsoft.Office.Interop.Excel.ApplicationClass();

Microsoft.Office.Interop.Excel.Workbook wb = xl.Workbooks.Add(-4167);
//Generic template

//Don't bother doing anything for now

wb = wb.Close(true,"C:\test.xls",null);

xl.Quit();

System.Runtime.InteropServices.Marshal.ReleaseComO bject(wb);

System.Runtime.InteropServices.Marshal.ReleaseComO bject(xl);

wb = null;

xl = null;

Please help, this is the last thing and we're releasing Monday!

Thanks, Jim

Jul 21 '05 #3

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

Similar topics

2
by: Duncan Allen | last post by:
I've been using excel within VB.NET applications and I can't get it to close down and remove itself from memory. I'm using Visual Studio 2003 ver 7.1.3088, Framework 1.1, MS Office 2003 with MS VS...
1
by: Rick Brown | last post by:
After reading 30+ threads on the subject and implementing pertinent changes I still have an instance of Excel that won't close. I hope its due to my poor coding and someone can spot the error....
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#...
7
by: Claudio Benghi | last post by:
Hello World, I've found a problem regarding Interop on Excel 2000. Here's KB article where the problem should be discussed: http://support.microsoft.com/default.aspx?scid=kb;EN-US;317109 ...
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...
2
by: Jim | last post by:
OK, now I'm really stumped. I have a ASP.NET w/ C# application that is using Excel XP to do automation. Everything works just great, but Excel stays resident in memory after I try to .Quit(). I...
16
by: alexia.bee | last post by:
Hi all, In some weird reason, excel instance won;t die if i remove the comment from 4 lines of setting values into struct. here is a snipcode public...
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
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...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.