PC Review


Reply
Thread Tools Rate Thread

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

 
 
Michael Tkachev
Guest
Posts: n/a
 
      18th Oct 2004
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.ApplicationClass a = new Excel.ApplicationClass();

.... // Here lies my code.

a.Quit();
while(System.Runtime.InteropServices.Marshal.ReleaseComObject(eRange) == 0);
while(System.Runtime.InteropServices.Marshal.ReleaseComObject(_Worksheet) ==
0);
while(System.Runtime.InteropServices.Marshal.ReleaseComObject(_Workbook) ==
0);
while(System.Runtime.InteropServices.Marshal.ReleaseComObject(a) == 0);

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

// Process[] p = Process.GetProcessesByName("EXCEL");
// foreach(Process pp in p)
// {
// pp.Kill();
// pp.Close();
// pp.Dispose();
// }

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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?RXRoZW0gQXp1bg==?=
Guest
Posts: n/a
 
      18th Oct 2004

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.ApplicationClass a = new Excel.ApplicationClass();
>
> .... // Here lies my code.
>
> a.Quit();
> while(System.Runtime.InteropServices.Marshal.ReleaseComObject(eRange) == 0);
> while(System.Runtime.InteropServices.Marshal.ReleaseComObject(_Worksheet) ==
> 0);
> while(System.Runtime.InteropServices.Marshal.ReleaseComObject(_Workbook) ==
> 0);
> while(System.Runtime.InteropServices.Marshal.ReleaseComObject(a) == 0);
>
> _Worksheet = null;
> eRange = null;
> _Workbook = null;
> a = null;
>
> // Process[] p = Process.GetProcessesByName("EXCEL");
> // foreach(Process pp in p)
> // {
> // pp.Kill();
> // pp.Close();
> // pp.Dispose();
> // }
>
> Thank you very much.
> --
> Sincerely yours,
> Michael Tkachev.
> ..Net Developer
>
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use pskill or kill ... to kill a process with a name like "Hello There" flahmeshess Microsoft Windows 2000 9 27th Oct 2009 06:13 AM
How to remove a running process that gives you "access denied" when you try to kill it jbclem Microsoft Windows 2000 0 10th May 2009 10:01 PM
Is there a better "kill" than "End process" in TaskManager? Kevin Yu Windows XP Help 4 18th Nov 2007 06:39 PM
Is there a better "kill" than "End process" in TaskManager? Kevin Yu Windows XP General 2 17th Nov 2007 12:58 PM
Error: "only part of read process memory or write process memory" =?Utf-8?B?amVmZmFsbGVu?= Windows XP Help 1 1st Jul 2004 12:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:54 PM.