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
>
>
>