By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,966 Members | 1,463 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,966 IT Pros & Developers. It's quick & easy.

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

P: n/a

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.ReleaseComO bject, 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.ReleaseComO bject(WorkBookObj);
// do
// {
// result =
System.Runtime.InteropServices.Marshal.ReleaseComO bject(WorkBookObj);
// }
// while( result == 0);
ComObj = null;
}
How can I solve this problem

Thank you

Leeor Chernov
R&D Department
SPLSoftware LTD.
ISRAEL


Dec 14 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
-------------------------------------------------------

"Leeor Chernov" <le***********@mod.gov.il> wrote in message
news:eA**************@TK2MSFTNGP12.phx.gbl...

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.ReleaseComO bject, 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.ReleaseComO bject(WorkBookObj);
// do
// {
// result =
System.Runtime.InteropServices.Marshal.ReleaseComO bject(WorkBookObj);
// }
// while( result == 0);
ComObj = null;
}
How can I solve this problem

Thank you

Leeor Chernov
R&D Department
SPLSoftware LTD.
ISRAEL


Dec 14 '05 #2

P: n/a
You should not be using Excel (or any of the Office products) w/ ASP.Net. It
is not threadsafe and not recommended by MS.
"Leeor Chernov" <le***********@mod.gov.il> wrote in message
news:eA**************@TK2MSFTNGP12.phx.gbl...

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.ReleaseComO bject, 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.ReleaseComO bject(WorkBookObj);
// do
// {
// result =
System.Runtime.InteropServices.Marshal.ReleaseComO bject(WorkBookObj);
// }
// while( result == 0);
ComObj = null;
}
How can I solve this problem

Thank you

Leeor Chernov
R&D Department
SPLSoftware LTD.
ISRAEL


Dec 14 '05 #3

P: n/a
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
-------------------------------------------------------

"Morgan" <ab**@senditon.com> wrote in message
news:eW*************@TK2MSFTNGP15.phx.gbl...
You should not be using Excel (or any of the Office products) w/ ASP.Net. It is not threadsafe and not recommended by MS.
"Leeor Chernov" <le***********@mod.gov.il> wrote in message
news:eA**************@TK2MSFTNGP12.phx.gbl...

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.ReleaseComO bject, 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.ReleaseComO bject(WorkBookObj);
// do
// {
// result =
System.Runtime.InteropServices.Marshal.ReleaseComO bject(WorkBookObj);
// }
// while( result == 0);
ComObj = null;
}
How can I solve this problem

Thank you

Leeor Chernov
R&D Department
SPLSoftware LTD.
ISRAEL



Dec 14 '05 #4

P: n/a
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...


"Morgan" <ab**@senditon.com> כתב
בהודעה:eW*************@TK2MSFTNGP15.phx.gbl...
You should not be using Excel (or any of the Office products) w/ ASP.Net. It is not threadsafe and not recommended by MS.
"Leeor Chernov" <le***********@mod.gov.il> wrote in message
news:eA**************@TK2MSFTNGP12.phx.gbl...

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.ReleaseComO bject, 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.ReleaseComO bject(WorkBookObj);
// do
// {
// result =
System.Runtime.InteropServices.Marshal.ReleaseComO bject(WorkBookObj);
// }
// while( result == 0);
ComObj = null;
}
How can I solve this problem

Thank you

Leeor Chernov
R&D Department
SPLSoftware LTD.
ISRAEL



Dec 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.