Excel.exe Process stays open in my "Task Manager" (C# ASP.Net Development)

L

Leeor Chernov

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
 
A

Alvin Bruney - ASP.NET MVP

I've seen some code in the performance newsgroup to loop thru the excel
processes open and shut them down. You should have a google for that code
and use it. Excel automation's biggest ugly spot is this.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
M

Morgan

You should not be using Excel (or any of the Office products) w/ ASP.Net. It
is not threadsafe and not recommended by MS.
 
A

Alvin Bruney - ASP.NET MVP

You really ought to qualify that statement. The recommendation concerns
server-side usage. Client-side usage is fine. Asp.NET can do both client and
server.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
L

Leeor Chernov

Hi Morgan ,
Can you send me an article-link that it isnot recomended?
And anyway it is MS product and the problem is to release the process...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top