473,770 Members | 5,976 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I kill an "Excel" process from a memory?

Hi Everybody,

I created an Excel file in the ASP.Net. When I wrote this file on the disk I
tryed to release COM objects. But I couldn't do it. When my method finished
an "Excel" process exists in the memory. So, I would like to kill an
"Excel" process and for it I need to know a ProcessID or something like
this. Who knows how can I get a processID or release COM objects?
Excel.Applicati onClass a = new Excel.Applicati onClass();

.... // Here lies my code.

a.Quit();
while(System.Ru ntime.InteropSe rvices.Marshal. ReleaseComObjec t(eRange) == 0);
while(System.Ru ntime.InteropSe rvices.Marshal. ReleaseComObjec t(_Worksheet) ==
0);
while(System.Ru ntime.InteropSe rvices.Marshal. ReleaseComObjec t(_Workbook) ==
0);
while(System.Ru ntime.InteropSe rvices.Marshal. ReleaseComObjec t(a) == 0);

_Worksheet = null;
eRange = null;
_Workbook = null;
a = null;

// Process[] p = Process.GetProc essesByName("EX CEL");
// foreach(Process pp in p)
// {
// pp.Kill();
// pp.Close();
// pp.Dispose();
// }

Thank you very much.
--
Sincerely yours,
Michael Tkachev.
..Net Developer
Nov 18 '05 #1
1 2305

Hi Michael,

First of all, there's no way that you can differentiate excel instantances
on memory if there's more than one instance active at the same time, (which
happens if there are two people trying to create an excel report) so you
would need to keep time stamps etc etc. My suggestion; screw this method.

Better way is to find why there's still an excel instance hanging on the
memory. This usually happens because of the COM Wrapper. We had such a
discussion before; take a look at this entry;

http://msdn.microsoft.com/newsgroups...2-630dc6d0b8c5

or search for "writting excel files" on this group.

Hope this helps,

Ethem Azun

"Michael Tkachev" wrote:
Hi Everybody,

I created an Excel file in the ASP.Net. When I wrote this file on the disk I
tryed to release COM objects. But I couldn't do it. When my method finished
an "Excel" process exists in the memory. So, I would like to kill an
"Excel" process and for it I need to know a ProcessID or something like
this. Who knows how can I get a processID or release COM objects?
Excel.Applicati onClass a = new Excel.Applicati onClass();

.... // Here lies my code.

a.Quit();
while(System.Ru ntime.InteropSe rvices.Marshal. ReleaseComObjec t(eRange) == 0);
while(System.Ru ntime.InteropSe rvices.Marshal. ReleaseComObjec t(_Worksheet) ==
0);
while(System.Ru ntime.InteropSe rvices.Marshal. ReleaseComObjec t(_Workbook) ==
0);
while(System.Ru ntime.InteropSe rvices.Marshal. ReleaseComObjec t(a) == 0);

_Worksheet = null;
eRange = null;
_Workbook = null;
a = null;

// Process[] p = Process.GetProc essesByName("EX CEL");
// foreach(Process pp in p)
// {
// pp.Kill();
// pp.Close();
// pp.Dispose();
// }

Thank you very much.
--
Sincerely yours,
Michael Tkachev.
..Net Developer

Nov 18 '05 #2

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

Similar topics

1
2526
by: CA | last post by:
I am having a problem getting a pointer to an existing running Excel process on a client machine. Here are some details: 1) I have tested out the code on the development machine and it works fine. (Excel XP) 2) The code works fine on a machine in our offices with Excel 2000. 3) On the client machine (with Excel 2000), the code does not work. I wrote some diagnostic tests to further try and see what was going on
11
2250
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 returns to the Web form to display. All is OK, except EXCEL remains in the process list in task manager. I am following all guideline in releasing the com components.
3
3337
by: hari krishna | last post by:
hi, I am generating excel reports through vb.Net. After creating excel.application and the report is generated, each report leaves Excel in memory. I can see them in task manager in Process tab (as EXCEL). So the memory has been taken by excel objects and memory is being full. i want to delete or kill this objects which are in memory. i wrote the code as 'myexcel.quit()' , myexcel=nothing. but still it is in memory. pls tell me how to...
2
5437
by: Praveen K | last post by:
I have a problem in communicating between the C# and the Excel Interop objects. The problem is something as described below. I use Microsoft Office-XP PIA dll’s as these dll’s were been recommended by many for web applications. I create the instances of Excel, Workbook and the worksheet. And later on Release the references by “System.Runtime.InteropServices.Marshal.ReleaseComObject(Object)” and making the object as null finally....
2
4895
by: charmis | last post by:
Hi everyone, I am trying to include one feature using excel object in my application. I am giving the code to create and kill the process , that i got from Microsoft site.......but nothing is happening it will create one process but , it wont close . i used the code from the link below:
2
21954
by: Powerguy | last post by:
Hi all, I am looking for a way to get the Process id (or a handle) of an EXCEL process created from within my code. For example when the following code is executed: Dim EXL As Excel.Application = New Excel.Application a new instance of EXCEL.EXE is created in the task manager.
16
4552
by: LP | last post by:
Hello, I am trying to use .NET with Excel. I installed Office 2003 and selected ..NET programming suport option, so it installed all those PIA, as MS sugests. But I can not find a way to destroy Excel process, it still hangs in the taks manager' Processes as running. I am trying very simple code (see below), but Excel wont go away, I tried just about anything I could find on MSDN or by Google. Even calling WIN32 API to destroy Excel. But...
2
2527
by: ChrisFrohlich | last post by:
I have been trying to use the Office PIA's to write an ASP.NEt page to: 1. Open a template workbook 2. Populate some data 3. Save the file back to the server 4. Quit Excel and free up Memory I have been able to do all of the above steps except #4. Each time Excel.exe persists in memory. I have already referred to Q317109 "Office application does not quit after automation from Visual Studio .NET client" without much luck.
0
1304
by: ravindarjobs | last post by:
dear friends, i am using ms access 2003. i wanted to export data from access table to excel table. so i have followed this Dim db As Database Dim ea As Excel.Application Dim rs As Recordset
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10058
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10004
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9870
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.