473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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


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
4 3700
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dudinissan | last post by:
Hello, I am writing c# web application with Excel 2000. My code is: Excel.Application EXL; EXL = new Excel.Application(); Excel.Worksheet WSheet = new Excel.WorksheetClass(); string FileName...
2
by: Praveen K | last post by:
I have a problem in communicating between the C# and the Excel Interop objects. The problem is something as described below. I use Microsoft Office-XP PIA dll’s as these dll’s were been...
3
by: Mike Eaton | last post by:
Hi there, I'm working on an application that opens an excel workbook, does some processing on the data contained in it, and then saves the data into the workbook. What I'm noticing is that once...
4
by: Powerguy | last post by:
Hi all, I've spent countless hours trying to get this silly EXCEL process to close once I have used it. If anyone can help it would really REALLy be appreciated! Below is my code- Dim t As...
2
by: Powerguy | last post by:
Hi all, I am looking for a way to get the Process id (or a handle) of an EXCEL process created from within my code. For example when the following code is executed: Dim EXL As...
16
by: LP | last post by:
Hello, I am trying to use .NET with Excel. I installed Office 2003 and selected ..NET programming suport option, so it installed all those PIA, as MS sugests. But I can not find a way to destroy...
1
by: Tony Hedge | last post by:
Hello, In my .NET code behind, I open up an excel file, and process all the rows in the worksheet that I'm interested in. Problem is when I'm done and issue the quit method. The EXCEL process...
4
by: Henry Stockbridge | last post by:
Hi, I am using Access 2003 to automate an Excel workbook, but after the code completes Excel does not quit (at least it is still listed in Task Manager --Processes.) I have set a reference to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.