ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Process is not terminated when using C# and com Interrop (https://www.excelbanter.com/excel-programming/301333-excel-process-not-terminated-when-using-c-com-interrop.html)

Hendrix4578

Excel Process is not terminated when using C# and com Interrop
 
How do you stop the Excel proces from running the following code works on some boxes but not others.It seems that it is impossible to terminate the Excel process.

if(ws != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComO bject(ws);
ws = null;
}
if(wb != null)
{
for(int i = 1 ;i < wb.Sheets.Count; i++)
{
((Excel.Worksheet)wb.Sheets[i]).Delete();
}

System.Runtime.InteropServices.Marshal.ReleaseComO bject(wb);
wb = null;
}

if(excelApp != null)
{
excelApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComO bject(excelApp);
excelApp = null;
}

System.GC.Collect();

It is not possible for me to use process.kill because the web based application that this used with ddoes not issue admin rights to its users.

Ramesh

Excel Process is not terminated when using C# and com Interrop
 
I am also having this problem exactly as same as Hendrix4578 has mentioned below. It is really killing me. Did anybody have any idea?

thanks
Ramesh

"Hendrix4578" wrote:
[i]
How do you stop the Excel proces from running the following code works on some boxes but not others.It seems that it is impossible to terminate the Excel process.

if(ws != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComO bject(ws);
ws = null;
}
if(wb != null)
{
for(int i = 1 ;i < wb.Sheets.Count; i++)
{
((Excel.Worksheet)wb.Sheets).Delete();
}

System.Runtime.InteropServices.Marshal.ReleaseComO bject(wb);
wb = null;
}

if(excelApp != null)
{
excelApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComO bject(excelApp);
excelApp = null;
}

System.GC.Collect();

It is not possible for me to use process.kill because the web based application that this used with ddoes not issue admin rights to its users.



All times are GMT +1. The time now is 07:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com