Group:  General ยป microsoft.public.officedev
Thread: Excel.exe Process stays open in my "Task Manager" (C# ASP.Net Development)

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Excel.exe Process stays open in my "Task Manager" (C# ASP.Net Development)
"Leeor Chernov" <leeor_chernov[ at ]mod.gov.il> 14.12.2005 17:33:51



Hi ,
I Used the object Excell Application(COM INTEROP) and it is staying as an
open process, And the owner(User Name) is ASPNET
Altough I try to release it with :
System.Runtime.InteropServices.Marshal.ReleaseComObject, And GC.Collect.
Every time I am opening a new Excel.Application() , I get more Processes in
memory.
Note: I am calling the CreateExcellObj each time I am pressing a button from
my web page
The release Methods sometimes release few Excell processes but the last one
always stays.

The Init method:

public void CreateExcellObj(string FilePath)
{

ExcelObj = new Excel.Application();


ExcelObj.Visible = true;
WorkBookObj = (Excel._Workbook) ExcelObj.Workbooks.Open(FilePath,
System.Reflection.Missing.Value,
true,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value);

}



The Release methods:

private void Release()
{

WorkBookObj.Close(false,System.Reflection.Missing.Value,System.Reflection.Mi
ssing.Value);
ReleaseComObject(oSheet);

ReleaseComObject(WorkBookObj);
ExcelObj.Workbooks.Close();
ReleaseComObject(ExcelObj.Workbooks);

ExcelObj.Quit();
ReleaseComObject(ExcelObj);

//GC.WaitForPendingFinalizers();
GC.Collect();

DALObj.UpdateFromDTAndAdapter( curTable, null);
return requestID;
}

private void ReleaseComObject(object ComObj)
{

int result;
result =
System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
// do
// {
// result =
System.Runtime.InteropServices.Marshal.ReleaseComObject(WorkBookObj);
// }
// while( result == 0);
ComObj = null;
}


How can I solve this problem

Thank you

Leeor Chernov
R&D Department
SPLSoftware LTD.
ISRAEL






Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net