473,395 Members | 1,679 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,395 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 5221
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: 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
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.